在tableview中上传异步图像,如即时消息

时间:2016-08-29 14:37:32

标签: objective-c uitableview chat image-uploading instant-message

我正在使用选项发送照片进行消息传递,一旦图像被挑选,它将被上传到服务器并显示在chatTableview列表中。但是我希望chatTableview的单元格也显示照片上传的进度。任何人都可以分享我的想法如何根据照片上传的状态更新chatTableview的单元格,例如微信?enter link description here

1 个答案:

答案 0 :(得分:0)

嗨,您可以使用多线程〜 例如,

NSBlockOperation *operation1 = [NSBlockOperation blockOperationWithBlock:^{
    NSLog(@"sending photo and update the progress of photo - %@", [NSThread currentThread]);
......
}];
NSBlockOperation *operation2 = [NSBlockOperation blockOperationWithBlock:^{
    NSLog(@"doing the messaging   - %@", [NSThread currentThread]);
......
}];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
[queue addOperations:@[operation1, operation2] waitUntilFinished:NO];