Yog*_*esh 13 objective-c uitabbarcontroller uitabbar ios swift
我正在尝试执行以下操作.
我有一个标签栏控制器,里面有2个标签.两个选项卡都是导航控制器,每个选项卡都有一个表视图.
现在,当我在第一个选项卡中选择表格的一个单元格时,我正在推动另一个标签栏控制器,所以我想隐藏父标签栏控制器的标签栏,当我单击导航栏上的后退按钮时,我希望再次查看父标签栏,因为我在父标签栏视图中.
我试过hidesbottombarwhenpushed并隐藏了父标签栏控制器标签栏但是当我点击它时它不会带回来.
Yog*_*esh 38
好的,最后我得到了答案,这就是我想要做的.
self.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:aViewController animated:YES];
self.hidesBottomBarWhenPushed=NO;
所以基本上hidesBottomBarWhenPushed = YES,然后推送你的视图控制器然后hidesBottomBarWhenPushed = NO; 这就像一个魅力.
接受的答案对我来说有问题.
我的应用程序有一个深度为三个UIViewController的导航.
我的解决方案是设置UINavigationControllerDelegate的委托
迅速:
self.navigationController?.delegate = self
Objective-C的:
self.navigationController.delegate = self;
然后实现以下委托方法
迅速:
fun navigationController(navigationController: UINavigationController, animationControllerForOperation operation: UINavigationControllerOperation, fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    if fromVC.isKindOfClass(FirstViewController) && toVC.isKindOfClass(SecondViewController) {
        self.hidesBottomBarWhenPushed = true;
    }
    else if fromVC.isKindOfClass(SecondViewController) && toVC.isKindOfClass(FirstViewController) {
        self.hidesBottomBarWhenPushed = false;
    }
    return nil
}
Objective-C的:
-(id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
                                 animationControllerForOperation:(UINavigationControllerOperation)operation
                                              fromViewController:(UIViewController*)fromVC
                                                toViewController:(UIViewController*)toVC
{
    if ([fromVC isKindOfClass:[FirstViewController class]] && [fromVC isKindOfClass:[SecondViewController class]]) {
        self.hidesBottomBarWhenPushed = true;
    }
    else if ([fromVC isKindOfClass:[SecondViewController class]] && [fromVC isKindOfClass:[FirstViewController class]]) {
        self.hidesBottomBarWhenPushed = false;
    }
    return nil;
}
希望它有所帮助.
| 归档时间: | 
 | 
| 查看次数: | 11020 次 | 
| 最近记录: |