使用UITableViewController和选项卡式导航的奇怪行为

时间:2013-03-25 14:03:47

标签: iphone ios objective-c xcode cocoa-touch

我有一个应用程序,其中要求是以标签格式布置部分。在其中一个选项卡下,将有一个表视图,其中包含一个细节视图的segue。当我在选项卡式导航之外设置此转换时,它可以正常工作。但是,当我尝试在选项卡式导航中执行此操作时,我收到运行时错误并崩溃。是否存在一个已知的问题,即尝试使用选项卡加载segue的tableview?

谢谢! VIV

1 个答案:

答案 0 :(得分:0)

以下是您如何使用UITabBarController

的简单示例

第一次在UIViewController文件中创建UINavigationControllerAppDelegate.h的所有对象,并使用以下AppDelegate.m

方法
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds ]];

    self.viewCon=[[ViewController alloc] init];
    self.navCon=[[UINavigationController alloc] initWithRootViewController:self.viewCon];
    self.navCon.navigationBar.tintColor=[UIColor blackColor];
    self.viewCon.title=@"First View";

    self.fView=[[FirstViewController alloc] init];
    self.FnavCon=[[UINavigationController alloc] initWithRootViewController:self.fView];
    self.FnavCon.navigationBar.tintColor=[UIColor blackColor];

    self.fView.title=@"Secound View";

    self.sView=[[SecoundViewController alloc] init];
    self.SnavCon=[[UINavigationController alloc] initWithRootViewController:self.sView];
    self.SnavCon.navigationBar.tintColor=[UIColor blackColor];
    self.sView.title=@"Third View";
    .
    .
    // create UIViewController and UINavigationController As you need 
    .
    .
    .
    UIImage *img1=[UIImage imageNamed:@"Australia.gif"];
    self.tbItem1=[[UITabBarItem alloc] initWithTitle:@"First Page" image:img1 tag:1];
    self.viewCon.tabBarItem=self.tbItem1;

    UIImage *img2=[UIImage imageNamed:@"Cameroon.gif"];
    self.tbItem2=[[UITabBarItem alloc] initWithTitle:@"Secound Page" image:img2 tag:2];
    self.fView.tabBarItem=self.tbItem2;

    UIImage *img3=[UIImage imageNamed:@"Canada.png"];
    self.tbItem3=[[UITabBarItem alloc] initWithTitle:@"Third Page" image:img3 tag:3];
    self.sView.tabBarItem=self.tbItem3;

    NSMutableArray *viewArr=[[NSMutableArray alloc] init];
    [viewArr addObject:self.navCon];
    [viewArr addObject:self.FnavCon];
    [viewArr addObject:self.SnavCon];


    self.tbCon=[[UITabBarController alloc] init];
    self.tbCon.viewControllers=viewArr;

    [self.window addSubview:tbCon.view];

    [self.window makeKeyAndVisible];

    return YES;
}