UIActionSheet cancel button not dismissing actions

2019-03-25 02:16发布

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?

6条回答
欢心
2楼-- · 2019-03-25 02:38

use

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

instead of

[actionSheet showInView:self.view];

this is working fine.. :-)

查看更多
Root(大扎)
3楼-- · 2019-03-25 02:44

Try this

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

UIActionSheet cancel button strange behaviour

查看更多
仙女界的扛把子
4楼-- · 2019-03-25 02:45

write simplite code

 actionSheet.actionSheetStyle = UIActionSheetStyleDefault;

this work fine

查看更多
Emotional °昔
5楼-- · 2019-03-25 02:46

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.

查看更多
Evening l夕情丶
6楼-- · 2019-03-25 02:49

This Will do the trick

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

instead of

[actionSheet showInView:self.view];
查看更多
ら.Afraid
7楼-- · 2019-03-25 02:55

I found the answer here.

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

[menu sendSubviewToBack:pickerView];
查看更多
登录 后发表回答