Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS itouch replaceObjectAtIndex导航栏消失_Ios_Iphone_Objective C_Uinavigationitem - Fatal编程技术网

iOS itouch replaceObjectAtIndex导航栏消失

iOS itouch replaceObjectAtIndex导航栏消失,ios,iphone,objective-c,uinavigationitem,Ios,Iphone,Objective C,Uinavigationitem,我有一系列设备,它们非常相似,由一个带有三个选项卡的小程序控制。在每个视图控制器中,我使用导航控制器来扩展这些特性中的每一个的设置 第一个选项卡“输入”选项卡在这三个设备之间尤其不同,因此当检测到我在设备之间切换时,我在我的应用程序委托中执行以下操作: if ([self IsCrescendo]) { //thirdViewController is really the crescendo'a input view - I need to rename that mess one d

我有一系列设备,它们非常相似,由一个带有三个选项卡的小程序控制。在每个视图控制器中,我使用导航控制器来扩展这些特性中的每一个的设置

第一个选项卡“输入”选项卡在这三个设备之间尤其不同,因此当检测到我在设备之间切换时,我在我的应用程序委托中执行以下操作:

if ([self IsCrescendo])
{
    //thirdViewController is really the crescendo'a input view - I need to rename that mess one day
    crescendoInputView = [[ThirdViewController alloc] init : (UIViewController*) currentViewController];
    crescendoInputView.title = [[viewControllers objectAtIndex:INPUT_TAB_INDEX] title];
    crescendoInputView.tabBarItem = [[viewControllers objectAtIndex:INPUT_TAB_INDEX] tabBarItem];
    [viewControllers replaceObjectAtIndex:INPUT_TAB_INDEX withObject:crescendoInputView];
    [crescendoInputView release];
    [self.tabBarController setViewControllers:viewControllers animated:FALSE];

}

if ([self IsSpirito3])
{ // similar to above using obviously a different view controller
}

if ([self IsSonata])
{ // similar to above using obviously a different view controller
}
最初,这个应用程序只控制一个设备,所以当我第一次创建它时,我在主窗口的XIB中设置了三个选项卡,效果很好。它默认为原始设备,并且导航栏处于活动状态。 现在有更多的设备需要控制,我想只使用replaceObjectAtIndex,所以在中交换一个新的视图控制器,但我的导航栏消失了

如果你能告诉我这件事,我将不胜感激。
谢谢

好的,在更多的挠头之后,下面的方法修复了它:

我最初使用主窗口的XIB来实例化这三个选项卡。 如果不进行替换ObjectAtIndex,则此操作非常有效。当我做一个ReplaceObjectAtIndex时,它会丢失导航栏

相反,如果以编程方式实例化选项卡,并且每个选项卡都有自己的导航控制器,则可以替换选项卡而不会丢失导航栏等功能

  • (BOOL)应用程序:(UIApplication*)应用程序使用选项完成启动:(NSDictionary*)启动选项 {

    self.window=[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]边界]]自动释放]; //应用程序启动后自定义的覆盖点

    //输入视图(默认为渐强)

    UIViewController*viewController1=[[ThirdViewController alloc]initWithNibName:@“ThirdView”捆绑包:nil]自动释放]; UINavigationController*nav1=[[UINavigationController alloc]initWithRootViewController:viewController1]

    //卷视图

    UIViewController*viewController2=[[SecondViewController alloc]initWithNibName:@“SecondView”捆绑包:nil]自动释放]; UINavigationController*nav2=[[UINavigationController alloc]initWithRootViewController:viewController2]

    //系统视图 UIViewController*viewController3=[[FirstViewController alloc]initWithNibName:@“FirstView”捆绑包:nil]自动释放]; UINavigationController*nav3=[[UINavigationController alloc]initWithRootViewController:viewController3]; self.tabBarController=[[UITabBarController alloc]init]autorelease]; self.tabBarController.viewControllers=[NSArray数组及其对象:nav1、nav2、nav3、nil]

。 . }

不确定从XIB设置它时为什么不起作用。我可以发誓,我让它在以前的版本上工作,所以可能有些东西改变了,苹果忘了告诉我们。 无论如何,我更喜欢这种方法。这已经不是第一次有“像向导一样”的编程工具咬我了,所以这可能会节省一些时间