[英]self.navigationController == nil
I tried to make a simple switch view function but it did not work then I tried to see if the second view is assigned and it was fine. 我试图制作一个简单的切换视图功能,但是它不起作用,然后尝试查看是否分配了第二个视图,并且很好。 The thing is that my
self.navigationControler
is nil
. 问题是我的
self.navigationControler
为nil
。 How do i fix that ? 我该如何解决?
ViewController2 *hs=[self.storyboard instantiateViewControllerWithIdentifier:@"Highscore"];
if(self.navigationController==nil)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"YOur Message" message:@"Your description"
delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alert show];
}
[self.navigationController pushViewController:hs animated:YES];
You will need to present the current view controller from a UINavigationController 您将需要通过UINavigationController展示当前的视图控制器
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:Your_Current_View_Controller];
//Now present controller in any way you want
After that your self.navigationController will not be nil anymoer 之后,您的self.navigationController将不会为零
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.