无法从UIImagePickerController

每当用户从ImagePicker我拿起图像的URL任何照片得到资产库

问题描述:

一个网址我想发送图像到服务器为它我正在显示PhotoLibrary无法从<code>UIImagePickerController</code></p> <p>每当用户从ImagePicker我拿起图像的URL任何照片得到资产库

但它显示在我不想(我的日志的输出)localUrl =assets-library://asset/asset.JPG?id=106E99A1-4F6A-45A2-B320-B0AD4A8E8473&ext=JPG

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 
    [picker dismissViewControllerAnimated:YES completion:^{ 

     NSURL* localUrl = (NSURL *)[info valueForKey:UIImagePickerControllerReferenceURL]; 
     NSLog(@"localUrl =%@",localUrl); 

    }]; 

} 

我想它是在file:///Users/Library/Developer/CoreSimulator/Devices/85CBED11-A318-4096-B52A-EBC3879F7B34/data/Containers/Data/Application/805BB62D-E32E-4D1E-99B6-C91103A1D99B/tmp/testing.doc

如何格式资产库的格式我做到了这一点?

请帮助和提前致谢!

+0

的可能的复制[交通资产类别pathForResource(http://*.com/questions/18968352/access-asset-catalog-pathforresource) – shallowThought

我不知道为什么你需要做这种情况。但你可以尝试。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 
    [picker dismissViewControllerAnimated:YES completion:^{  
     NSData *pngData = UIImagePNGRepresentation(ivPickedImage.image); 
     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
     NSString *documentsPath = [paths objectAtIndex:0]; //Get the docs directory 
     NSString *filePath = [documentsPath stringByAppendingPathComponent:@"image.png"]; //Add the file name 
     [pngData writeToFile:filePath atomically:YES]; //Write the file 
     NSLog(@"localUrl =%@",filePath); 
    }]; 
}