【问题标题】:how to change view controller using uisegmentcontroller in objective c如何在目标 c 中使用 uisegment 控制器更改视图控制器
【发布时间】: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];

【问题讨论】:

    标签: ios uisegmentedcontrol


    【解决方案1】:

    您需要自定义视图控制器容器。 你可以在这里得到很好的例子https://www.objc.io/issues/12-animations/custom-container-view-controller-transitions/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-12-09
      • 1970-01-01
      • 2015-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多