1

大家好,我有这个 i 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
        }
}

我在这里错过了什么吗?

4

2 回答 2

2

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

- (IBAction)showCurl:(id)sender {
        alert1 = [[UIAlertView alloc] initWithTitle:@"Loading" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert1 show]; 
}
于 2012-05-03T16:45:53.303 回答
0

您的代码没有显示按钮

 alert1 = [[UIAlertView alloc]initWithTitle:@"Loading" message:nil delegate:self cancelButtonTitle:**nil** otherButtonTitles:**nil**];

您将 nil 作为 cancelButtonTitle 和 nil 作为 otherbuttonTitles 传递,您至少应该设置一个按钮标题。

于 2012-05-03T17:03:36.023 回答