我尝试做一个简单的切换 View 功能但是没有用
然后我尝试查看是否分配了第二个 View 并且没问题。
问题是我的 self.navigationControler
是 nil
。
我该如何解决?
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];
最佳答案
您需要从 UINavigationController 中呈现当前 View Controller
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:Your_Current_View_Controller];
//Now present controller in any way you want
在那之后你的 self.navigationController 将不再是 nil
关于iphone - self.navigationController == 无,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10929335/