0
我想在我的項目中添加一個標籤欄。假設我有六個視圖控制器。現在我試圖添加標籤欄只有視圖控制器的第三個數字。我怎樣才能做到這一點?我試圖做到這一點。我在app delegate.m中添加了代碼,但是在應用程序委託中編寫代碼後,效果進入所有視圖控制器。在IOS中如何在特定的UIViewController中添加UITabBarController
我想在我的項目中添加一個標籤欄。假設我有六個視圖控制器。現在我試圖添加標籤欄只有視圖控制器的第三個數字。我怎樣才能做到這一點?我試圖做到這一點。我在app delegate.m中添加了代碼,但是在應用程序委託中編寫代碼後,效果進入所有視圖控制器。在IOS中如何在特定的UIViewController中添加UITabBarController
將這個代碼在自定義的UITabBarController
-(void)setTabBarHidden:(BOOL)hidden {
CGRect screenRect = [[UIScreen mainScreen] bounds];
float fHeight = screenRect.size.height;
if(UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)){
fHeight = screenRect.size.width;
}
if(!hidden) fHeight -= self.tabBar.frame.size.height;
[UIView animateWithDuration:0.25 animations:^{
for(UIView *view in self.view.subviews){
if([view isKindOfClass:[UITabBar class]]){
[view setFrame:CGRectMake(view.frame.origin.x, fHeight, view.frame.size.width, view.frame.size.height)];
}else{
if(hidden) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];
}
}
}
}completion:^(BOOL finished){
if(!hidden){
[UIView animateWithDuration:0.25 animations:^{
for(UIView *view in self.view.subviews)
{
if(![view isKindOfClass:[UITabBar class]]) {
if (!hidden) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];
for(UIView *view in self.view.subviews){
if([view isKindOfClass:[UITabBar class]]){
[view setFrame:CGRectMake(view.frame.origin.x, fHeight, view.frame.size.width, view.frame.size.height)];
}else{
if(hidden) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];
}
}
}
}
}
}
}];
}
}];}
在的UITabBarController
的這種委託方法- (BOOL)tabBarController:(UITabBarController*)tabBarController shouldSelectViewController:(UIViewController*)viewController
你可以做一個請檢查是否顯示或隱藏的TabBar根據其的viewController是
因爲你必須隱藏並顯示你的標籤欄在你想要的任何控制器。 –
請添加代碼示例。 –
檢查此:http://stackoverflow.com/questions/19999532/how-to-add-uiviewcontroller-as-subview-to-be-visible-above-tabbar/20000657#20000657 –