繁体   English   中英

我怎么知道我的视窗?

[英]How do I know the window of my view?

ViewWillAppear永远不会自动调用,我必须手动调用它们。 虽然经常会调用ViewWillDisappear

我不知道在哪里调试。

我想问题是因为我在4.1上创建了应用程序,因此人们必须显式调用viewWillAppear

我想,因为将根据viewWillAppear与窗口的关系来调用它,所以我可以检查viewController是否具有窗口出口。

我该怎么做?

我怀疑问题出在我的代表中:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [Crashlytics startWithAPIKey:@"a08863b514ef09558ba82fec070cc7468fdbeeae"];
    if(getenv("NSZombieEnabled") || getenv("NSAutoreleaseFreedObjectCheckEnabled"))
    {
        NSLog(@"NSZombieEnabled/NSAutoreleaseFreedObjectCheckEnabled enabled!");
    }

    [self.window addSubview:self.navController.view]; //This seem to be the problem. I should have specified the viewController and not the view

    [self.navController pushViewController:self.MainBadgerApplication animated:YES];
    //[cachedProperties singleton].lastAnchor =[cachedProperties currentLocation];
    [cachedProperties singleton].currentAnchor=[cachedProperties currentLocation];
    self.MainBadgerApplication.selectedIndex=0;
    [BNUtilitiesQuick tabBarController:self.MainBadgerApplication didSelectViewController:self.MainBadgerApplication.selectedViewController];
    [self.window makeKeyAndVisible];

    return YES;
}

我怀疑[self.window addSubview:self.navController.view]; 是问题。

我也听说过在ios5之前,您必须显式调用viewController。 所以我应该为ios5和ios4创建一个不同的程序(不像我的程序两次调用viewController会有危险)

我怀疑[self.window addSubview:self.navController.view]; 是问题。

大概。 您应该这样做:

self.window.rootViewController = self.navController;

仅添加视图并不能将您的视图控制器正确地放入层次结构中。 有关更多信息,请参阅WWDC 2011视图控制器包含视频。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM