をプッシュのUIViewControllerは、ポップのUIViewControllerの後UITabBar
にカスタムボタンを追加する前に、自己にカスタムボタンを復元します。ビュー
サブクラスUITabViewController
NSArray *array= self.viewControllers;
for(UIViewController *controller in array){
if([controller isKindOfClass:[UINavigationController class]]){
UINavigationController *navigationController=(UINavigationController*)controller;
navigationController.delegate=self;
}
}
デリゲートメソッドを実装する
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
if (viewController.hidesBottomBarWhenPushed) {
CGRect rect= [button convertRect:button.bounds toView:self.tabBar];
[button removeFromSuperview];
[self.tabBar addSubview:button];
button.frame=rect;
}
}
-(void)navigationController:(nonnull UINavigationController *)navigationController didShowViewController:(nonnull UIViewController *)viewController animated:(BOOL)animated{
if(!viewController.hidesBottomBarWhenPushed){
CGRect rect= [button convertRect:button.bounds toView:self.view];
[button removeFromSuperview];
[self.view addSubview:button];
button.frame=rect;
}
}
私は[self.tabBar addSubView:button]を試してみました。しかし、それは動作しません – carbonr
これが助けることを望むhttp://stackoverflow.com/questions/11225696/how-to-hide-custom-tab-bar-button-when-hidesbottombarwhenpushed-is-true?rq=1 – vamsi575kg