0

我一直在寻找几个小时,但没有找到任何答案,所以非常感谢您的帮助!

我正在设计一个应用程序,当按下警报中的按钮时,需要切换到不同的视图控制器。我已经设置了警报,但只需要代码来切换到新视图。

4

3 回答 3

3

尝试这个。首先创建警报视图。

UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Message"  message:@"Open New controller?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes",nil];
[alertView show];
[alertView release];

实现 AlertView 委托方法

#pragma mark AlertView Delegate
-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex != alertView.cancelButtonIndex)
    {
        Viewcontroller *vc = [[UIViewcontroller alloc] initWithNib:@"Viewcontroller"];
        [self presentModalViewController:vc];
        [vc release];
    }
}
于 2012-08-14T17:26:01.683 回答
1

实现UIAlertViewDelegate并添加方法alertView:clickedButtonAtIndex:。单击右键后,调用该方法以进入新视图。

于 2012-08-14T17:23:31.773 回答
0

实施UIAlertViewDelegate,然后你会得到一个回调,当警报被解除时按下哪个按钮。只需performSegueWithIdentifier在那里打电话。

UIAlertViewDelegate 协议参考中的更多详细信息

于 2012-08-14T17:23:22.420 回答