简体   繁体   English

UIActionSheet取消按钮不解除动作表

[英]UIActionSheet cancel button not dismissing actionsheet

I have an UIActionSheet and I am specifying the cancel button however it does not dismiss when its tapped? 我有一个UIActionSheet,我正在指定取消按钮但是当它点击时它不会被忽略?

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? 根据文档,我不需要任何代码,甚至当我尝试实现didCancel委托方法时,它从未调用过?

Try this 试试这个

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

UIActionSheet cancel button strange behaviour UIActionSheet取消按钮奇怪的行为

This Will do the trick 这将成功

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

instead of 代替

[actionSheet showInView:self.view];

use 使用

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

instead of 代替

[actionSheet showInView:self.view];

this is working fine.. :-) 这工作正常...... :-)

如果在视图中使用显示,则需要从iPhone上的任务栏或工具栏进行显示,因为它会剪切某些控件。

write simplite code 编写简化代码

 actionSheet.actionSheetStyle = UIActionSheetStyleDefault;

this work fine 这项工作很好

I found the answer here. 我在这里找到了答案。

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

[menu sendSubviewToBack:pickerView];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM