Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.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 tabBarController在调用modalView后卸载自身_Ios_Objective C_Uitabbarcontroller_Modal View - Fatal编程技术网

Ios tabBarController在调用modalView后卸载自身

Ios tabBarController在调用modalView后卸载自身,ios,objective-c,uitabbarcontroller,modal-view,Ios,Objective C,Uitabbarcontroller,Modal View,我有6个视图的tabBarController。作为默认的tabBarController load first视图,我需要在应用程序启动时加载视图#6,因此在我的tabBarController中,我添加到视图将出现[self.tabBarController setSelectedIndex:6],好的。在我看来#3 a有两个模态视图,我在故事板中创建了它们。当我点击一个按钮时,我加载我的模式视图,当一个按钮关闭它时,[自我解除ModalViewController激活:是];(我在视图#3

我有6个视图的tabBarController。作为默认的tabBarController load first视图,我需要在应用程序启动时加载视图#6,因此在我的tabBarController中,我添加到
视图将出现
[self.tabBarController setSelectedIndex:6],好的。在我看来#3 a有两个模态视图,我在故事板中创建了它们。当我点击一个按钮时,我加载我的模式视图,当一个按钮关闭它时,
[自我解除ModalViewController激活:是]
;(我在视图#3)我看到了视图#6,但我需要回到视图#3,所以如果我在调用我的modalView时理解正确,它将卸载我的tabBarController,当我关闭它时再次使用视图#6加载tabBarController,但我需要在调用我的modalView时看到我的视图#6,我如何修复它


另外,我希望您能理解我的英语

看起来您添加了
[self.tabBarController setSelectedIndex:6]
视图将出现
,而不是
viewDidLoad
。没有将加载的视图。

请在选项卡栏控制器的ViewDidDisplay方法中执行类似操作,以便仅在应用程序启动时设置selectedIndex:

-(void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    static BOOL isFirst = YES;
    if (isFirst) {
        [self setSelectedIndex:6];
        isFirst = NO;
    }
}

我在脚本中更改tabBarController中项目的顺序,在代码中更改视图的数量,一切正常。感谢大家。

您的理解是错误的——当您呈现一个模态控制器时,不会卸载选项卡栏控制器。@rdelmar不正确,但视图将在modalView关闭后显示。如何修复它?如果我把它放在viewDidLoad我的应用程序加载第一页而不是six@RomanSimenok,你的评论是什么意思?您是否收到错误消息?如果,那么您需要发布您尝试过的代码。是的,错误,但ViewDidDisplay是错误的方式,例如,即使我将[self.tabBarController setSelectedIndex:6]放在那里;它总是将我发送到6页,因此只有viewWillLoad在这里工作,我尝试在那里设置come“if”,但我得到的只是错误。@RomanSimenok,它不应该总是将你发送到6页,只有在视图第一次出现时。我已经测试了我的代码,对我来说效果很好。正如我上面所说的,您应该编辑您的问题以显示您现在使用的代码。