Multithreating(多线程)
网络请求例子:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://..."]]; NSURLSessionConfiguration *configuration = nil; NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration]; NSURLSessionDownloadTask *task; task = [session downloadTaskWithRequest:request completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) { dispatch_async(dispatch_get_main_queue(), ^{/* do UI thing */}); // or [self performSelectorOnMainThread:@selector(doUIthings) withObject:nil waitUntilDone:NO]; }]; [task resume];
在完成网络请求后,做一些UI操作,UI操作是在主线程完成
UIScrollView(滚动视图)
注意:需要设置scrollView的contentSize
scrollView.contentSize = CGSizeMake(3000, 2000);
设置缩放比例
scrollView.minimumZoomScale = 2.0;
scrollView.minimumZoomScale = 0.2;