Close Child View from Parent
For some reason when I close my child view it causes an error with my webvi开发者_如何转开发ew (in the parent view). The call I am using to close the child view: (I don't know if this is the right way to do it)
[normalSplashScreen_vc closeNormalSplashScreen];
Gives me the following error:
Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
I can't figure out why closing a child view effects the underlying webview?
(I think by calling the closeNormalSplashScreen
function I am closing the main view even though it is called in the child view - if this is the case how do I remedy this problem?)
Main View
@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];
}
SplashScreen
The Two splash screens are essentially the same (with the firstRun one having a progress bar).
@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];
}
Relates to this and this question. (The second one doesn't answer the question... is it possible?)
This error usually shows up when you do a UI operation from a thread which is not the main thread.
Where are you calling the method closeNormalSplashScreen from? Is it being called from a different thread than the main thread?
Try doing this and see if the error still comes up
[normalSplashScreen_vc performSelectorOnMainThread:@selector(closeNormalSplashScreen) withObject:nil waitUntilDone:YES]; //last argument will change depending on your requirement
精彩评论