2017-09-24 70 views
0

下面是一段Android代碼正常工作,我必須在iOS中編寫相同的登錄名和類型,編寫,特別是使用imageBytes的Base64編碼。如何用iOS(Objective-C)編寫以下Android(A-Java)代碼

ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos); 
byte[] imageBytes = baos.toByteArray(); 
String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT); 
return encodedImage; 

回答

0

下面將是完全等效..

UIImage *image = [UIImage imageWithData:byteArrayData]; 
NSData *imageBytes = UIImageJPEGRepresentation(image, 1.0); 
NSString *encodedImage = [imageBytes base64EncodedStringWithOptions:0]; 
+0

感謝:-)將檢查並恢復 –