【发布时间】:2014-01-03 10:29:27
【问题描述】:
我的代码:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *prePath = [[spineArray objectAtIndex:spineIndex - 1] spinePath];
NSURL *preURL = [NSURL fileURLWithPath:prePath];
UIWebView *tmpWebView = [self createWebView:preURL];
dispatch_async(dispatch_get_main_queue(), ^{
self.preWebView = tmpWebView;
});
});
- (UIWebView *)createWebView:(NSURL *)url
{
UIWebView *tmpWebView = [[[UIWebView alloc] initWithFrame:CGRectMake(0, 0,kRootViewWidth, kRootViewHeight)] autorelease];
tmpWebView.delegate = self;
[tmpWebView setBackgroundColor:[UIColor whiteColor]];
currentTextSize = 100;
UISwipeGestureRecognizer *rightSwipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(gotoNextPage)];
[rightSwipeRecognizer setDirection:UISwipeGestureRecognizerDirectionLeft];
UISwipeGestureRecognizer *leftSwipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(gotoPrevPage)];
[leftSwipeRecognizer setDirection:UISwipeGestureRecognizerDirectionRight];
[tmpWebView addGestureRecognizer:rightSwipeRecognizer];
[tmpWebView addGestureRecognizer:leftSwipeRecognizer];
[rightSwipeRecognizer release];
[leftSwipeRecognizer release];
[tmpWebView loadRequest:[NSURLRequest requestWithURL:url]];
return tmpWebView;
}
我们运行的时候,提示错误是:
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...
【问题讨论】:
标签: ios multithreading