UIActionSheet cancel button not dismissing actionsheet

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 03:43:26

问题


I have an UIActionSheet and I am specifying the cancel button however it does not dismiss when its tapped?

UIActionSheet *actionSheet = [[[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Target Complete" otherButtonTitles:nil] autorelease]; 
[actionSheet showInView:self.view];

According to the documentation I don't need any code and even when I try and implement the didCancel delegate method its never called?


回答1:


Try this

[actionSheet showInView:[self.view window]];

UIActionSheet cancel button strange behaviour




回答2:


This Will do the trick

[actionSheet showInView:[self.view window]];

instead of

[actionSheet showInView:self.view];



回答3:


use

[actionSheet showFromTabBar:[[self tabBarController] tabBar]];

instead of

[actionSheet showInView:self.view];

this is working fine.. :-)




回答4:


You need to display from a taskbar or a toolbar on iPhone as it clips some of the controls if you use display in view.




回答5:


write simplite code

 actionSheet.actionSheetStyle = UIActionSheetStyleDefault;

this work fine




回答6:


I found the answer here.

https://stackoverflow.com/a/1530259/1803218

[menu sendSubviewToBack:pickerView];


来源:https://stackoverflow.com/questions/8550579/uiactionsheet-cancel-button-not-dismissing-actionsheet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!