只想在Xcode中找出如何設置2個線程運行? 例如上傳文件(大小大小爲3-4 MB)到網站 ,它允許用戶繼續使用該應用程序,而無需使用該上傳文件來阻止他執行其他操作。如何在iPhone應用程序正在做其他事情時在後臺上傳文件
我知道我可以在頂欄上顯示網絡活動圖標,但不知道如何分離線程。
UIApplication* app = [UIApplication sharedApplication];
app.networkActivityIndicatorVisible = YES;
有什麼想法嗎? 謝謝
什麼樣,如果我用void dispatch_async( dispatch_queue_t隊列, dispatch_block_t塊); – 2012-08-16 08:35:42
您可以使用[GCD API](https://developer.apple.com/library/mac/#documentation/Performance/Reference/GCD_libdispatch_Ref/Reference/reference.html),但對於您在使用NSOperation的問題中提到的任務會更合適。你可以找到更多關於併發編程的信息[here](https://developer.apple.com/library/mac/#documentation/General/Conceptual/ConcurrencyProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008091 ) – mijokaliger 2012-08-16 08:47:06
我遇到錯誤「void _WebThreadLockFromAnyThread(bool),0x2f45b0:從主線程或Web線程以外的線程獲取Web鎖定。不應從輔助線程調用UIKit。而我使用代碼 UIStoryboard * mainStoryboard = [UIStoryboard storyboardWithName:kMAINSTORYBOARD bundle:nil]; UIViewController * controller =(UIViewController *)[mainStoryboard instantiateViewControllerWithIdentifier:kMAINNAVIGATION]; controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:controller animated:YES]; – 2012-08-17 02:50:39