【问题标题】:Triggering the UIViewController connected to the UITabBarItem触发连接到 UITabBarItem 的 UIViewController
【发布时间】:2011-07-28 03:49:08
【问题描述】:

大家好

我有一个应用程序,它有一个用于选项卡式导航的 UITabBarController...视图控制器通过 URL 映射到它们各自的 TabItems,就像 Three20 的 TTNavigationSample 应用程序一样。

我的问题是,在我的视图控制器中,我有一个按钮可以调用另一个视图控制器,该控制器也附加到 TabItem。当我触发按钮时,应用程序会引发错误。我该如何解决这个问题?

在我的 TabBarController 中,我在 viewDidLoad 方法中有这个:

-(void)viewDidLoad {
 [self setTabURLs: [NSArrayWithObjects:
                    @"tt://bulletinBoard",
                    @"tt://contacts",
                    nil
                   ]];
}

【问题讨论】:

  • 您遇到什么错误?通常,您尝试的方案是可行的......

标签: ios uitabbarcontroller three20


【解决方案1】:

.m 文件示例

#import "HabBarController.h"


@implementation TabBarController


- (void)viewDidLoad {

    //these are variables like "tt/feed"
    [self setTabURLs:[NSArray arrayWithObjects:
                      kAppFeedURLPath,
                      kAppHotURLPath,
                      kAppPostPhotoURLPath,
                      kAppGeneralActivityURLPath,
                      nil]];


}

- (UIViewController*)rootControllerForController: 
(UIViewController*)controller {

    if ([controller canContainControllers]) { 

        return controller; 
    } else { 
        UINavigationController* navController = [[[UINavigationController 
                                                   alloc] init] autorelease]; 
        [navController pushViewController:controller animated:NO]; 
        return navController; 
    } 
} 


- (void)viewWillDisappear:(BOOL)animated { 
    [super viewWillDisappear:animated]; 
    [self.tabBarController.navigationController setNavigationBarHidden:YES animated:NO];

} 
- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];


}

- (void)viewDidUnload {
    [super viewDidUnload];
}


- (void)dealloc {
    [super dealloc];
}

@end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-14
    • 2012-06-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多