3

我一直在互联网上寻找解决此问题的方法,但找不到我能理解的方法。就这样吧。我有我的 iOS 应用程序,在第一次启动应用程序时,它会显示一个 UIAlertView。我想要其中一个按钮将用户发送到新的 viewController 以查看一些基本信息。

我已经正确配置了 UIAlertView,这是 actionSheet 的代码:

- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0)
{

//Code to open a new viewController???


}

if (buttonIndex == 1)
{

//User can exit the application if they do not wish to continue

exit(0);    }

}
}

我创建了一个名为 webViewViewController 的 viewController,这就是我希望用户在点击第一个按钮时达到的内容。关于如何做到这一点的任何想法?我禁用了 ARC,我遇到的其他“解决方案”不断给我错误。

谢谢大家,希望能得到一些指导。

4

3 回答 3

0

如果您当前的视图控制器位于导航控制器中:

UIViewController *myViewController = [[UIViewController alloc] init];
myViewController.title = @"My First View";
//to push the UIView.
[self.navigationController pushViewController:myViewController animated:YES];

并且永远不要使用exit(0)!

于 2013-01-21T11:56:40.490 回答
0
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0)
{

 NewViewController *controller=[[NewViewController alloc]initWithNibName:@"NewViewController" bundle:nil];
            self.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;
            [self presentViewController:controller animated:YES completion:nil];



}           

drasick 已经给出了足够的答案,但是如果您需要使用模型视图控制器,请参考上面。

于 2013-01-21T12:11:06.720 回答
0

利用:

UIViewController *yourViewController = [[UIViewController alloc] init];
[self.navigationController presentModalViewController:myViewController animated:YES];

推送一个modalViewController。(这在iOS 6中被贬低,但会起作用)

于 2013-01-21T12:54:57.683 回答