UIActionSheet取消按钮不解除动作表

The*_*ner 12 iphone uiactionsheet ios

我有一个UIActionSheet,我正在指定取消按钮但是当它点击时它不会被忽略?

UIActionSheet *actionSheet = [[[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Target Complete" otherButtonTitles:nil] autorelease]; 
[actionSheet showInView:self.view];
Run Code Online (Sandbox Code Playgroud)

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

nev*_*ing 42

试试这个

[actionSheet showInView:[self.view window]];
Run Code Online (Sandbox Code Playgroud)

UIActionSheet取消按钮奇怪的行为


hac*_*ack 14

这将成功

[actionSheet showInView:[self.view window]];
Run Code Online (Sandbox Code Playgroud)

代替

[actionSheet showInView:self.view];
Run Code Online (Sandbox Code Playgroud)


The*_*ner 3

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