我通過多方同行中ios7文件使用此方法發送:MCSession multipeer背景
_progressSend = [session sendResourceAtURL:imageUrl withName: info toPeer:peerID withCompletionHandler:^(NSError *error) {
// Implement this block to know when the sending resource transfer completes and if there is an error.
if (error) {
NSLog(@"Send resource to peer [%@] completed with Error [%@]", peerID.displayName, error);
}
else {
// Create an image transcript for this received image resource
}
}];
的問題是很奇怪的。這是發生了什麼事:
設備開始發送資源,進度條開始填滿。當我將應用程序置於後臺並檢查我的電子郵件時,傳輸仍在繼續(我可以從其他設備的進度條中看到)。如果傳輸已完成,並且我回到應用程序中,則一切正常,但如果我在傳輸資源時進入應用程序(例如,我退出1/3的路並以2/3打開它)應用程序完全凍結,需要從多任務欄中關閉。但Xcode不顯示崩潰。這就好像應用程序一直運行,但用戶界面完全凍結。有沒有人有想法?
發生這種情況是因爲委託方法未從主線程調用。 –