iOS开发:通过按下警报中的按钮Segue? [英] iOS Dev: Segue by pressing a button in an Alert?
本文介绍了iOS开发:通过按下警报中的按钮Segue?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在搜索几个小时,没有找到任何答案,所以我非常感谢您的帮助!
I've been searching for a few hours and haven't found any answers, so I would really appreciate your help!
我正在设计一个应用程序,需要当按下警报中的按钮时,切换到不同的视图控制器。我已经设置了警报,但只需要代码来浏览一个新的视图。
I am designing an app and need to segue to a different view controller when a button in an alert is pressed. I already have the alert set up, but just need the code to segue to a new view.
推荐答案
尝试这个。先创建alertview。
Try this. create alertview first.
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Message" message:@"Open New controller?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes",nil];
[alertView show];
[alertView release];
实施AlertView委托方法
Implement the AlertView Delegate Method
#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];
}
}
这篇关于iOS开发:通过按下警报中的按钮Segue?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文