[英]UIAlertView button to another ViewController
I have two buttons for my UIAlertView
. 我的
UIAlertView
有两个按钮。 One of them goes back to TableViewController
while another one have to go to another ViewController
. 其中一个返回到
TableViewController
而另一个必须返回到另一个ViewController
。 The button that goes to the TableViewController
can work. 转到
TableViewController
的按钮可以工作。 But the button that goes to the ViewController
is showing me a blank view when I click the button. 但是当我单击按钮时,转到
ViewController
的按钮向我显示了空白视图。
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
QuizTableViewController *quizTable = [self.storyboard instantiateViewControllerWithIdentifier:@"quizTable"];
UINavigationController *quizController = [[UINavigationController alloc] initWithRootViewController:quizTable];
[quizController setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentViewController:quizController animated:YES completion:nil];
}
if (buttonIndex == 1)
{
QuizAnsViewController *quizAns = [[QuizAnsViewController alloc] initWithNibName:nil bundle:nil];
[self presentViewController:quizAns animated:YES completion:nil];
}
}
The second part of the code is for the button to go another ViewController
. 代码的第二部分是使按钮转到另一个
ViewController
。
Anybody can help please? 有人可以帮忙吗? Thank you.
谢谢。
It seems you are using Story board so this might work 看来您正在使用故事板,所以这可能有效
if (buttonIndex == 1){
QuizAnsViewController *quizAns = [self.storyboard instantiateViewControllerWithIdentifier:@"Identifier_of_that_view_controller"];
[self presentViewController:quizAns animated:YES completion:nil];
}
you use NavigationController than I think this code is Solve your problem. 您使用NavigationController比我认为这段代码可以解决您的问题。 You can Try.
你可以试试。
if (buttonIndex == 1)
{
QuizAnsViewController * quizAns = [[[QuizAnsViewController alloc] initWithNibName:@"QuizAnsViewController" bundle:nil] autorelease];
[self.navigationController quizAns animated:YES];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.