2011-07-25 267 views
0

我正在与ShareKit合作,这是iOS应用程序的开源共享基础。有一个已知的错误,阻止Kit检测你的根视图控制器是什么。该错误的修正是在应用程序委托中添加[SHK setRootViewController:myViewController];根视图控制器?

如果修复方法是在UIApplication didFinishLaunching方法中,那么视图控制器是不是仅仅是self?我错过了什么?我也试过self.viewController,self.window.rootViewControllerself.window无济于事。

编辑:这里就是整个didFinishLoading

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    // Override point for customization after application launch. 
    self.viewController = [[Chatter_BoxViewController alloc] initWithNibName:@"Chatter_BoxViewController" bundle:nil]; 
    self.window.rootViewController = self.viewController; 
    [self.window makeKeyAndVisible]; 
    [SHK setRootViewController:self.viewController]; 

    return YES; 
} 

回答

2

如果它只会在didFinishLaunching将参考UIApplication的,你不同意“自我”?你是否正确启动了viewController?张贴更多的代码。 :)

评论您编辑:

如果您在窗口中的厦门国际银行通常设置你不需要这样的:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 

另外,如果你这样做(假设你的viewController是保留为财产):

self.viewController = [[Chatter_BoxViewController alloc] initWithNibName:@"Chatter_BoxViewController" bundle:nil]; 

您将有泄漏。只是这样做:

viewController = [[Chatter_BoxViewController alloc] initWithNibName:@"Chatter_BoxViewController" bundle:nil]; 
+0

在编辑中添加了代码,让我知道你在想什么。 –

+0

编辑我的文章。 – Peres

+0

这些只是iOS 5基于视图的应用程序的默认值,我没有改变它们。由于iOS 5中的ARC,我不必担心'self.viewController'泄漏。我仍然想知道'[SHK]'这一行。 –