Dismissing a navigation view controller

て烟熏妆下的殇ゞ 提交于 2020-01-01 11:45:53

问题


I am currently working on a game for the iOS platform. The game's initial view controller is a login screen, and once the player logs in, he gets to a loading screen, and then a navigation view controller containing a table view with a list of current games. The storyboard's relevant view relations look like this:

[login screen] --modalsegue-> [loading screen] --modalsegue-> [navigation controller] --relationship-> [tableview (with logout button)]

I want to make a logout button at the bottom bar of the navigation view's [table view], which takes the player back to the [login screen]. How can I do this?

Thanks in advance!


回答1:


You can dismiss, self.presentingViewController.presentingViewController or you can use dismissToRootViewController.




回答2:


[self.navigationController dismissViewControllerAnimated:YES completion:nil];




回答3:


- (void)viewDidLoad
{
     [super viewDidLoad];
     UIBarButtonItem *btnLogout = [[UIBarButtonItem alloc]initWithTitle:@"Logout" style:UIBarButtonItemStyleBordered target:self action:@selector(btnOnClick:)];
     self.navigationItem.rightBarButtonItem = btnLogout;
}
-(void)btnOnClick:(id)sender
{
     [self.presentingViewController.presentingViewController dismissModalViewControllerAnimated:YES];
}

I hope...This may help you...



来源:https://stackoverflow.com/questions/20471761/dismissing-a-navigation-view-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!