我需要通过SWRevealViewController
为第二个视图控制器设置为root。但是当我打电话给pushFrontViewcontroler
时,它变成了一个空白屏幕。我在故事板中定义的所有标签都丢失了。但外部xib i include正确显示。我错过了什么吗?请赐教我如何解决这个问题。下面是我用来调用第二个视图控制器的代码。
SWRevealViewController * revealController = self.revealViewController;
ImageDetailViewController *imageViewController = [[ImageDetailViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:imageViewController];
[revealController pushFrontViewController:navigationController animated:YES];
我也尝试使用它但仍然失败
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:imageViewController];
[self.revealViewController setFrontViewController:navigationController];
[self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];
答案 0 :(得分:0)
您的主要问题是imageViewController的实例化
ImageDetailViewController *imageViewController = [[ImageDetailViewController alloc] init];
如果你做这样的事情
ImageDetailViewController *imageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"MyImageViewController"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:imageViewController];
[revealController pushFrontViewController:navigationController animated:YES];
这很完美,但我仍然建议您在故事板上安装navViewControllers,并将其更改为此代码
- (void) goMainViewControllerAction
{
UINavigationController* navigationController = [self.storyboard instantiateViewControllerWithIdentifier:@“MainNavViewController”];
[self.revealViewController pushFrontViewController:navigationController animated:YES];
}
//
- (void) goImageViewControllerAction
{
UINavigationController* navigationController = [self.storyboard instantiateViewControllerWithIdentifier:@"MyImageNavViewController"];
[self.revealViewController pushFrontViewController:navigationController animated:YES];
}
我希望这有助于你