2012-11-23 141 views
0

我在iOS Storybords中有一个Tab-bar应用程序。 UITabbar控制器连接到 - > 4套(U导航控制器 - > UItableview控制器)。每个UITableviewcontroller单元连接到多个UIview控制器以进行推送。标签栏显示整个项目?

构建应用程序 - 导航选项卡出现在视图控制器的顶部,没有任何问题。但是底部有4个项目的Tabbar仅在第一个视图中可见。 UIviewcontrollers不显示4项Tabbar!??。我已将底部栏设置为属性检查器中的选项卡栏。但它不起作用?

我相信一定还有比我理解的更多的东西。希望有人帮助。

如何在应用程序中显示tabbar?

回答

1

我对你的设计并不完全确定,但是这里有一些提示可能会有所帮助。

分镜设计:

基本的TabBar应用布局总体上应该是这样的,从左至右为上的小箭头,表明它是启动控制电路左侧的第一个控制器。

  • 您的第一控制器应该是的TabBar控制器
  • 每个标签应该被连接到导航控制器
  • 每个导航控制器应连接到一个或多个UIViewControllers或UITableViewControllers。

现在,请注意,虽然有高级配置,但这只是一般布局,可以很好地设置应用程序并为每个选项卡提供轻松的推送转换。

如果您的应用程序启动并显示标签栏,并且当您选择标签项时,它应该显示该标签的视图控制器。如果tabbar仍然存在,那么你的状态很好。如果您在该视图控制器上选择了一些内容,并在屏幕上推动了一个新的视图控制器,那么在这种情况下,您会丢失标签栏,那么可能是这个问题: - 检查视图控制器并查看对象检查器以查看标记为“隐藏底部栏” - 如果选中 - 则取消选中它。 如果你没有找到它,然后检查你的代码为你的视图控制器,并寻找启动方法,如视图加载的声明:self.hidesBottomBarWhenPushed = YES;如果您找到该命令,请将其注释掉或删除它。

如果这是您的设计并且在您的应用程序中有意义,那么可以隐藏某些视图控制器上的tabbar是完全可以的。一般来说,尝试和避免它并将屏幕保留在屏幕上是一种很好的做法,以便用户体验,但有时像屏幕大小等问题可能会导致开发人员在某些工作流程中隐藏它。

我希望这会有所帮助,并与您的问题联系起来。如果没有,对不起。

0

UINavigationController S中UITabbarController!而非周围您可以添加标签栏像这样的其他方式

+0

您的建议似乎很有希望,但我无法显示它。你能否解释一点细节 - 可能是一步一步来的。我非常感谢。 – Sivon

+0

我在UITabbarcontroller中嵌入了四个UINavigationController,然后将一个UITableViewcontroller连接到每个导航控制器。但仍然没有在UIviewcontroller中显示标签栏的运气(在单击表格视图单元格时出现在视图中) – Sivon

+0

我不太清楚您的意思,但我看到您接受了答案,所以我想您会找到解决方案。 –

1

内: -

Appdelegate.h

#import <UIKit/UIKit.h> 

@class StartingViewController; 

@interface Appdelegate : NSObject <UIApplicationDelegate> { 
    UIWindow *window; 
    StartingViewController *viewController; 

    UITabBarController *tabBarController; 
} 

@property (nonatomic, retain) IBOutlet UIWindow *window; 
@property (nonatomic, retain) IBOutlet StartingViewController *viewController; 

@property (nonatomic,retain) UITabBarController *tabBarController; 

-(void)addTabBarToView; 

@end 

应用delegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  

    // Override point for customization after application launch. 

    // Add the view controller's view to the window and display. 
    [window addSubview:viewController.view]; 
    [window makeKeyAndVisible]; 

    [self addTabBarToView]; 

    return YES; 
} 

-(void)addTabBarToView{ 

    FirstController *first = [[FirstController alloc] initWithNibName:@"FirstController" bundle:nil]; 
    first.title = @"First"; 

    SecondController *second = [[SecondController alloc] initWithNibName:@"SecondController" bundle:nil]; 
    second.title = @"Second"; 

    ThirdController *three = [[ThirdController alloc] initWithNibName:@"ThirdController" bundle:nil]; 
    first.title = @"Third"; 

    Forthcontrooler *Four4 = [[Forthcontrooler alloc] initWithNibName:@"Forthcontrooler" bundle:nil]; 
    second.title = @"Secfor"; 





    UINavigationController *navigationController1 = [[UINavigationController alloc] initWithRootViewController:first]; 

    UINavigationController *navigationController2 = [[UINavigationController alloc]initWithRootViewController:second]; 

    UINavigationController *navigationController3 = [[UINavigationController alloc] initWithRootViewController:three]; 

    UINavigationController *navigationController4 = [[UINavigationController alloc]initWithRootViewController:Four4]; 



    tabBarController = [[UITabBarController alloc] init];   

    tabBarController.viewControllers = [NSArray arrayWithObjects:navigationController1,navigationController2,navigationController3,navigationController4,nil]; 

    [window addSubview:tabBarController.view]; 

}