嗨,大家好,我将此IBAction链接到一个按钮:

- (IBAction)showCurl:(id)sender {
        alert1 = [[UIAlertView alloc]initWithTitle:@"Loading" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
        [alert1 show];

}

和一个clickedButtonIndex自动运行,但是不知何故它不会加载SecondViewController:
#pragma mark UIAlertView
- (void)alertView:(UIAlertView *)alert1 clickedButtonAtIndex:(NSInteger)buttonIndex {
    if(buttonIndex == 0){
        SecondViewController *sampleView = [[SecondController alloc] init];
        [sampleView setModalTransitionStyle:UIModalTransitionStylePartialCurl];
        [self presentModalViewController:sampleView animated:YES];
        }
    else{
            // Cancel prompt
        }
}

我在这里想念什么吗?

最佳答案

如果您没有为警报视图提供某些按钮标题,则不会有任何按钮可以点击,并且不会调用该委托方法。

- (IBAction)showCurl:(id)sender {
        alert1 = [[UIAlertView alloc] initWithTitle:@"Loading" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert1 show];
}

关于objective-c - clickedButtonAtIndex:不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10435632/

10-10 11:48