【问题标题】:Whose view is not in the window hierarchy in iOS 6.1iOS 6.1 中谁的视图不在窗口层次结构中
【发布时间】:2017-09-08 19:56:58
【问题描述】:

收到此错误。

2013-02-28 16:19:49.628 VLC[1416:907] 警告:尝试呈现不在窗口层次结构中的视图!

这是我的代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // This will mark crashy files
    [[MLMediaLibrary sharedMediaLibrary] applicationWillStart];

    [_window addSubview:self.navigationController.view];
    [_window setRootViewController:self.navigationController];
    [_window makeKeyAndVisible];


    NSURL * urlToOpen = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
    urlToOpen = [NSURL URLWithString:@"rtsp://192.168.4.123"];

    if (urlToOpen != nil) {
        // We were started to open a given URL
        MVLCMovieViewController * movieViewController = [[MVLCMovieViewController alloc] init];
        movieViewController.url = urlToOpen;

        [self.navigationController presentViewController:movieViewController animated:YES completion:NULL];
        [movieViewController release];
    }

    return YES;
}

【问题讨论】:

    标签: ios objective-c ios6


    【解决方案1】:

    在添加到 window 之前,您尚未使用 UIViewController 初始化您的 navigationController。

    试试看:

    YourViewController *object_yvc = [[YourViewController alloc] initWithNibName:@"YourViewController"
                                                                                bundle:[NSBundle mainBundle]];
    UINavigationController *navObject_vc = [[UINavigationController alloc] initWithRootViewController:object_yvc];
    

    【讨论】:

      猜你喜欢
      • 2012-12-03
      • 2016-09-03
      • 1970-01-01
      • 1970-01-01
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多