【发布时间】:2015-11-27 20:00:27
【问题描述】:
我想在点击段时更改视图控制器。我在底部有UITabBarItem,所以当我点击第二段或第一段时,当前视图控制器内的视图应该会发生变化。
当我使用该代码时,整个视图与当前视图重叠,这不是我想要的。
if([sender selectedSegmentIndex] == 0) {
// UIStoryboard *mystoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
// UITabBarController *wc = [mystoryboard instantiateViewControllerWithIdentifier:@""];
// [self.navigationController pushViewController:wc animated:YES];
NSLog(@"first");
} else if([sender selectedSegmentIndex] == 1) {
// UIStoryboard *mystoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
// UITabBarController *wc = [mystoryboard instantiateViewControllerWithIdentifier:@"ProfileViewController"];
// [self.navigationController pushViewController:wc animated:YES];
NSLog(@"Second");
UIStoryboard *mystoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ProfileViewController *wc = [mystoryboard instantiateViewControllerWithIdentifier:@"ProfileFirstViewController"];
[self.navigationController pushViewController:wc animated:YES];
【问题讨论】: