我想在单击片段时更改视图控制器。我在底部有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];
答案 0 :(得分:0)
您需要自定义视图控制器容器。 你可以在https://www.objc.io/issues/12-animations/custom-container-view-controller-transitions/
得到很好的例子