Ios 为什么ClickedButtonIndex方法甚至在UIActionSheet的外侧被调用?

Ios 为什么ClickedButtonIndex方法甚至在UIActionSheet的外侧被调用?,ios,iphone,objective-c,cocoa-touch,uiactionsheet,Ios,Iphone,Objective C,Cocoa Touch,Uiactionsheet,正如我的标题所说,clickedbuttonationindexdelegate方法是调用,甚至点击UIActionSheet的外侧。 当我点击ui按钮时,会显示我的操作表。 myUIActionSheet声明的代码 -(void)btnComplexityTapped:(UIButton *) sender { UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select your complexi

正如我的标题所说,
clickedbuttonationindex
delegate方法是调用,甚至点击UIActionSheet的外侧。
当我点击
ui按钮
时,会显示我的操作表。 myUIActionSheet声明的代码

-(void)btnComplexityTapped:(UIButton *) sender
{
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select your complexity" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Easy", @"Medium", @"High", nil];
    [actionSheet showFromRect:sender.frame inView:self.view animated:YES];
    [actionSheet release];
}
和在委托方法中

- (void)actionSheet:(UIActionSheet *)myActionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if(buttonIndex == 0)
    {
        [self.btnComplexity setTitle:@"Easy" forState:UIControlStateNormal];
    }
    else if(buttonIndex == 1)
    {
        [self.btnComplexity setTitle:@"Medium" forState:UIControlStateNormal];
    }
    else
    {
        [self.btnComplexity setTitle:@"High" forState:UIControlStateNormal];
    }
}
我知道,通过将委托方法中的最后一个条件设置为设置
else if(buttonIndex==1)
而不是仅设置
else
,可以解决此问题。但我不想应用任何修复,但我想知道为什么调用委托方法,即使我没有点击
UIActionSheet的任何按钮

请参阅此视频以获得更清晰的图片

如上所述,当我点击按钮时,按钮的默认标题为“中”,然后操作表打开,我点击操作表的外侧(如
self.view
),然后委托方法
ClickedButtonIndex
被调用,所以最后一个
否则
条件变为真,这就是我的按钮标题变为“高”的方式


有谁能告诉我为什么会这样

在iPad中,行动表以一个弹出框呈现。没有取消按钮,因为触摸popover外的按钮相当于触摸cancel。因此,您的学员会收到消息,就好像触摸了取消按钮一样。

在iPad中,动作表以弹出窗口显示。没有取消按钮,因为触摸popover外的按钮相当于触摸cancel。因此,您的学员会收到消息,就像触摸了取消按钮一样。

因为它出现在
POPOVER
iPad)中,而在操作表上没有取消按钮。如果您点击操作表,则会触发其
cancel

因为它出现在
POPOVER
iPad)它在操作表上没有取消按钮。如果您点击操作表,它的
cancel
将被触发