【发布时间】:2016-11-09 13:25:33
【问题描述】:
我正在使用 AFNetworking 在服务器上上传视频文件,它在后台模式下工作正常,当应用程序处于前台时,但当我锁定屏幕时,它停止上传并且没有给出任何错误并转到完成处理程序。 这是代码
AFURLConnectionOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setUploadProgressBlock:^(NSUInteger __unused bytesWritten,
long long totalBytesWritten,
long long totalBytesExpectedToWrite) {
NSLog(@"Wrote Data %lld/%lld", totalBytesWritten, totalBytesExpectedToWrite);
[self setProgress:(float)totalBytesWritten/(float)totalBytesExpectedToWrite];
}];
typeof(operation) __weak weakOperation = operation;
[operation setCompletionBlock:^{
if([weakOperation isFinished]) {
[SVProgressHUD showSuccessWithStatus:DISCUSSION_SAVE_SUCCESS];
} else {
[SVProgressHUD showErrorWithStatus:ERROR];
}
}];
[operation start];
【问题讨论】:
标签: ios objective-c