简体   繁体   English

self.navigationController ==无

[英]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.navigationControlernil 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.

相关问题 添加子视图后self.navigationController为nil - self.navigationController is nil after adding subview self.navigationController为null - self.navigationController is null self.navigationController始终使用故事板到故事板导航返回nil - self.navigationController always returns nil using storyboard to storyboard navigation titleView仅在一个视图控制器中起作用(self.navigationController为nil) - titleView only works in one view controller (self.navigationController is nil) self.navigationController pushViewController 不工作 - self.navigationController pushViewController not working self.navigationController的不同值(nil和non-nil)取决于堆栈位置 - Different values (nil and non-nil) for self.navigationController depending on stack location 通过openURLAction进行Three20导航; self.navigationController在推送的VC中为零吗? - Three20 navigation by openURLAction; self.navigationController is nil in pushed VC? 为什么self.navigationController在viewDidLoad中为null? - Why is self.navigationController null in viewDidLoad? iphone - [[tabBarController] navigationController]和self.navigationController之间的区别 - iphone - Difference between [[self tabBarController] navigationController] and self.navigationController 更改UIViewControllers self.navigationController的值? - Changing the UIViewControllers self.navigationController value?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM