我想将图像保存到 ios 相机胶卷中。它在模拟器中运行良好。
但在实际的 iPhone 上,我没有得到这样的权限提示:
- (void)saveImageToCameraRoll:(CDVInvokedUrlCommand*)command
{
CDVPluginResult* pluginResult = nil;
NSString *filename = [command argumentAtIndex:0];
NSString *tmpFile = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", filename]];
UIImage *image = nil;
image = [UIImage imageWithContentsOfFile:tmpFile];
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
if(status != ALAuthorizationStatusAuthorized || image == nil){
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"noaccess"];
}
else{
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"saved"];
}
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
有什么办法可以强制吗?
谢谢。干杯。