[英]TabBar is not visible on navigating into another UIViewController
[英]Unable to make tabbar visible
我有一個應用程序,在其中我可以隱藏事件並在其中顯示標簽欄,以下是我使用的方法,當我嘗試隱藏它時,它可以正常工作。 但是,當我嘗試使其可見時,它不起作用。
-(void)setTabBarVisible:(BOOL)visible animated:(BOOL)animated completion:(void (^)(BOOL))completion {
// RootViewController* tabBarController = (RootViewController*)self.navigationController.parentViewController.parentViewController;
UITabBarController *tabBarController = self.tabBarController;
CGFloat duration = (animated)? 0.3 : 0.0;
CGRect frame = tabBarController.tabBar.frame;
CGFloat height = frame.size.height;
CGFloat offsetY = (visible)? -height : height;
CGRect playerFrame = player.view.frame;
CGRect toolBarFrame = self.toolbar.frame;
[UIView animateWithDuration:duration animations:^{
CGRect fr = CGRectOffset(frame, 0, offsetY);
tabBarController.tabBar.frame = fr;
if((!visible && ![self toolBarOnBottom]) || visible) {
self.toolbar.frame = CGRectOffset(toolBarFrame, 0, offsetY);
[self.toolbar layoutIfNeeded];
}
} completion:completion];
}
當我第二次調試代碼時,我再次調用此方法使其可見,因此標簽欄框架為零,我認為這是問題所在。 我正在使用iOS 11 SDK在Xcode 9上對此進行測試。 我不確定安全區是否與此有關。
任何幫助,將不勝感激。
當我想得到一個可行的解決方案時,最終使用了它,可以與自動布局和安全區域完美配合
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.