iOS TabBarController 问题

发布于 2024-12-11 07:02:48 字数 764 浏览 2 评论 0原文

TabBar将是关于2个问题。我使用 TabBar 和 NavigationController 的组合。如以下链接。

http://developer.apple.com/library/ios/ #featuredarticles/ViewControllerPGforiPhoneOS/CombiningViewControllers/CombiningViewControllers.html

问题 1:

我想出现在另一个 ViewController 的 TabBar 之前。这里要做几项检查。 (例如,Facebook 登录)如果满足先决条件,选项卡栏将可见。我该怎么办?

问题2:

TabBar 屏幕图标出现在第一个TabBar 的中间。下面的代码顺序也会影响TabBarItem的顺序。

self.tabBarController.viewControllers = [NSArray arrayWithObjects: viewController1, viewController2, nil];

谢谢。

奥坎·沙辛

TabBar will be about 2 question. I am using a combination of a TabBar and NavigationController. As the following link.

http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/CombiningViewControllers/CombiningViewControllers.html

Question 1:

I would like to appear before a TabBar to another ViewController. Several checks are here to do. (For example, Facebook login) If the prerequisites are met, tabbar will be visible. How do I do?

Question 2:

TabBar screen icon that appears in the middle of the first TabBar want it to be. The following code sequence also affects the order of TabBarItem.

self.tabBarController.viewControllers = [NSArray arrayWithObjects: viewController1, viewController2, nil];

Thank you.

Okan Sahin

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黑凤梨 2024-12-18 07:02:48

对于那些有同样问题的人:

我正在使用 Xcode 4.2。我创建了选项卡式应用程序。

答案 1:

对于加载屏幕,

我创建了一个新的 ViewController。

AppDelegate.m

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

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    UIViewController *viewControllerLoading = [[LoadingViewController alloc] initWithNibName:@"LoadingViewController" bundle:nil];

    self.window.rootViewController = viewControllerLoading;

    [self.window makeKeyAndVisible];

    return YES;
}

LoadingViewController.h

@interface LoadingViewController : UIViewController <UITabBarControllerDelegate>

@property (strong, nonatomic) UITabBarController *tabBarController;

@end

LoadingViewController.m

 UIViewController *viewControllerFriends = [[FriendsViewController alloc] initWithNibName:@"FriendsViewController" bundle:nil];
    UINavigationController* navController1 = [[UINavigationController alloc]
                                              initWithRootViewController:viewControllerFriends];
    UIViewController *viewConrollerMessages = [[MessagesViewController alloc] initWithNibName:@"MessagesViewController" bundle:nil];
    UINavigationController* navController2 = [[UINavigationController alloc]
                                              initWithRootViewController:viewConrollerMessages];
    UIViewController *viewControllerWorld = [[WorldViewController alloc] initWithNibName:@"WorldViewController" bundle:nil];
    UINavigationController* navController3 = [[UINavigationController alloc]
                                              initWithRootViewController:viewControllerWorld];

    UIViewController *viewControllerCheckIn = [[CheckInViewController alloc] initWithNibName:@"CheckinViewController" bundle:nil];
    UINavigationController* navController4 = [[UINavigationController alloc]
                                              initWithRootViewController:viewControllerCheckIn];

    UIViewController *viewControllerProfile = [[ProfileViewController alloc] initWithNibName:@"ProfileViewController" bundle:nil];
    UINavigationController* navController5 = [[UINavigationController alloc]
                                              initWithRootViewController:viewControllerProfile];

    self.tabBarController = [[UITabBarController alloc] init];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:navController1, navController2, navController3, navController4, navController5, nil];

    [self.view addSubview:self.tabBarController.view];

答案 2:

    self.tabBarController.selectedIndex = 2;

最诚挚的问候

Okan Sahin

For those who have the same problem:

I'm using Xcode 4.2. I have created Tabbed App.

Answer 1:

For loading screen,

I created a new ViewController.

AppDelegate.m

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

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    UIViewController *viewControllerLoading = [[LoadingViewController alloc] initWithNibName:@"LoadingViewController" bundle:nil];

    self.window.rootViewController = viewControllerLoading;

    [self.window makeKeyAndVisible];

    return YES;
}

LoadingViewController.h

@interface LoadingViewController : UIViewController <UITabBarControllerDelegate>

@property (strong, nonatomic) UITabBarController *tabBarController;

@end

LoadingViewController.m

 UIViewController *viewControllerFriends = [[FriendsViewController alloc] initWithNibName:@"FriendsViewController" bundle:nil];
    UINavigationController* navController1 = [[UINavigationController alloc]
                                              initWithRootViewController:viewControllerFriends];
    UIViewController *viewConrollerMessages = [[MessagesViewController alloc] initWithNibName:@"MessagesViewController" bundle:nil];
    UINavigationController* navController2 = [[UINavigationController alloc]
                                              initWithRootViewController:viewConrollerMessages];
    UIViewController *viewControllerWorld = [[WorldViewController alloc] initWithNibName:@"WorldViewController" bundle:nil];
    UINavigationController* navController3 = [[UINavigationController alloc]
                                              initWithRootViewController:viewControllerWorld];

    UIViewController *viewControllerCheckIn = [[CheckInViewController alloc] initWithNibName:@"CheckinViewController" bundle:nil];
    UINavigationController* navController4 = [[UINavigationController alloc]
                                              initWithRootViewController:viewControllerCheckIn];

    UIViewController *viewControllerProfile = [[ProfileViewController alloc] initWithNibName:@"ProfileViewController" bundle:nil];
    UINavigationController* navController5 = [[UINavigationController alloc]
                                              initWithRootViewController:viewControllerProfile];

    self.tabBarController = [[UITabBarController alloc] init];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:navController1, navController2, navController3, navController4, navController5, nil];

    [self.view addSubview:self.tabBarController.view];

Answer 2:

    self.tabBarController.selectedIndex = 2;

Best regards

Okan Sahin

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文