从父母关闭儿童视图

时间:2011-04-21 02:06:56

标签: iphone objective-c cocoa-touch memory-management

由于某些原因,当我关闭我的子视图时,它会导致我的webview出错(在父视图中)。我用来关闭子视图的调用:(我不知道这是否是正确的方法)

  

[normalSplashScreen_vc closeNormalSplashScreen];

给我以下错误:

  

尝试从主线程或Web线程以外的线程获取Web锁定。这可能是从辅助线程调用UIKit的结果。现在崩溃......

我无法弄清楚为什么关闭子视图会影响基础webview?

(我想通过调用closeNormalSplashScreen函数来关闭主视图,即使它在子视图中被调用 - 如果是这种情况我该如何解决这个问题呢? )


主视图

@interface turfplusViewController : UIViewController {
    IBOutlet splashScreen *FirstRunsplashScreen_vc;
    IBOutlet NormalSplashScreen *normalSplashScreen_vc;
    IBOutlet UIWebView *Webview;
}

@property(nonatomic, retain) splashScreen *FirstRunsplashScreen_vc;
@property(nonatomic, retain) NormalSplashScreen *normalSplashScreen_vc;

// Obviously these functions are declared correctly but for the sake of space

 - (void) displayFirstRunSplashScreen { 
    [self presentModalViewController:FirstRunsplashScreen_vc animated:NO];
}

- (void) displayNormalSplashScreen {
    [self presentModalViewController:normalSplashScreen_vc animated:NO];
}

闪屏

两个初始屏幕基本相同(firstRun有一个进度条)。

@interface NormalSplashScreen : UIViewController {
    IBOutlet UIActivityIndicatorView *NormalActivityIndicator;
}

@property(nonatomic, retain) UIActivityIndicatorView *NormalActivityIndicator;

// Obviously these functions are declared correctly but for the sake of space

- (void) closeNormalSplashScreen {
    [self dismissModalViewControllerAnimated:YES];
}

thisthis问题相关。 (第二个没有回答这个问题......有可能吗?)

1 个答案:

答案 0 :(得分:1)

当您从不是主线程的线程执行UI操作时,通常会显示此错误。

你从哪里调用closeNormalSplashScreen方法?它是从与主线程不同的线程调用的吗?

尝试这样做并查看错误是否仍然出现

[normalSplashScreen_vc performSelectorOnMainThread:@selector(closeNormalSplashScreen) withObject:nil waitUntilDone:YES]; //last argument will change depending on your requirement
相关问题