由于某些原因,当我关闭我的子视图时,它会导致我的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];
}
答案 0 :(得分:1)
当您从不是主线程的线程执行UI操作时,通常会显示此错误。
你从哪里调用closeNormalSplashScreen方法?它是从与主线程不同的线程调用的吗?
尝试这样做并查看错误是否仍然出现
[normalSplashScreen_vc performSelectorOnMainThread:@selector(closeNormalSplashScreen) withObject:nil waitUntilDone:YES]; //last argument will change depending on your requirement