iOS 7 - 在呈现模态视图控制器时获取警告消息 [英] iOS 7 - Getting warning message while presenting modal view controller

查看:76
本文介绍了iOS 7 - 在呈现模态视图控制器时获取警告消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用iOS 7编译和运行 - 我收到警告消息:不鼓励在分离的视图控制器上显示视图控制器,同时提供模态视图控制器。我从未遇到iOS 6或更早版本的问题。任何人都可以在呈现模态视图控制器时显示是否有任何变化?

Compiling and running using iOS 7 - I am getting warning message: "Presenting view controllers on detached view controllers is discouraged" while presenting modal view controller. I never had problem with iOS 6 or earlier version. Can anyone show if anything changed while presenting the modal view controller?

SearchViewController *controller1;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    controller1 = [[SearchViewController alloc] initWithNibName:@"SearchViewController-iPad" bundle:nil];
}
else
{
   controller1 = [[SearchViewController alloc] initWithNibName:@"SearchViewController" bundle:nil];
}
controller1.delegate = self;
[[self navigationController] presentModalViewController:controller1 animated:YES];

* 编辑* 这是代码有人可以指出它在哪里嵌套。
看起来它们是嵌套的,请建议如何使用子视图控制器模式进行链接。

*EDIT * Here is the code Can someone point out where it is nested. Looks like they are nested, Please suggest how to link using child viewcontroller pattern.

(void)applicationDidFinishLaunching:(UIApplication *)application
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        self.loginRootviewController =   [[MainViewController alloc] initWithNibName:@"MainViewController-iPad" bundle:nil];
    }
    else
    {
       self.loginRootviewController =   [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
    }

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.loginRootviewController];


    DDMenuController *rootController = [[DDMenuController alloc] initWithRootViewController:navController];
    _menuController = rootController;



    AppMainMenuViewController *leftController = [[AppMainMenuViewController alloc] init];
    rootController.leftViewController = leftController;
    self.loginRootviewController.delegateLogin = leftController;

    self.window.rootViewController = rootController;

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];

}


推荐答案

一个视图如果故事板不知道以任何方式将该视图控制器连接回根视图控制器的任何segue,则分离控制器。

A view controller is detached if the story board is not aware of any segues that connect that view controller in any way back to the root view controller.

建议您创建一个segue通过Interface Builder并在代码中调用它,即使是模态视图,如果你使用的是故事板。

It's suggested that you create a segue via Interface Builder and call it in code, even for a modal view, if you are using a storyboard.

即使使用XCode 4.6.x和iOS 6.x,你也可以在构建时有关未连接的视图控制器的警告。

Even with XCode 4.6.x and iOS 6.x, you got warnings at build time about unattached view controllers.

如果你有两个故事板(一个用于iPhone,一个用于iPad),你可以为每个设置相同的segue。 Segue标识符只需每个故事板是唯一的。因此,执行segue( performSegueWithIdentifier )使用相同的标识符可以将您带到iPhone的一个地方,另一个放在iPad上。

If you have two storyboards (one for iPhone and one for iPad), you can name the segue the same for each. Segue identifiers only have to be unique per storyboard. So, performing a segue (performSegueWithIdentifier) with the same identifier can take you to one place on the iPhone and another on the iPad.

这篇关于iOS 7 - 在呈现模态视图控制器时获取警告消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆