大家好,我把这个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
}
}
我在这里错过了什么吗?
答案 0 :(得分:2)
如果您没有给警报视图提供一些按钮标题,则不会有任何按钮可以点击,也不会调用该委托方法。
- (IBAction)showCurl:(id)sender {
alert1 = [[UIAlertView alloc] initWithTitle:@"Loading" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert1 show];
}
答案 1 :(得分:0)
您的代码未显示按钮
alert1 = [[UIAlertView alloc]initWithTitle:@"Loading" message:nil delegate:self cancelButtonTitle:**nil** otherButtonTitles:**nil**];
你将nil作为cancelButtonTitle传递给nil作为otherbuttonTitles,你至少应该设置一个按钮标题。