所以我正在获取这个 UIImage 数据并将其转换为 base64 中的字符串。问题是它在转换时挂在 UI 线程上,我不知道为什么。
- (void)processImage:(UIImage*)image{
dispatch_queue_t myQueue = dispatch_queue_create("My Queue",NULL);
[self.spinnerOutlet setAlpha:0.0f];
[self.spinnerOutlet startAnimating];
dispatch_async(myQueue, ^{
// Convert image
NSData *myData = [UIImagePNGRepresentation(image) base64EncodedDataWithOptions:NSDataBase64Encoding64CharacterLineLength];
NSString *myString = [NSString stringWithUTF8String:[myData bytes]];
dispatch_async(dispatch_get_main_queue(), ^{
// Update the UI
[self showSuccessAlertView:@"Success!" message:@"Submitting Image..."];
snapShotInBase64 = myString;
[self sendImagePostRequest];
});
});
}