piz*_*lms 23 uiimagepickercontroller
我有一个视图控制器,需要能够从相册和相机中选择一张图片.我只能为didFinishPickingMediaWithInfo提供一个委托方法,虽然我可以判断它是否是一个图像,我似乎无法判断它是来自相册还是来自相机(我需要先将它保存在相册中).信息中有什么可以帮我区分这两个吗?
谢谢...
cam*_*dez 51
因为UIImagePickerController传递给方法,所以你要做的就是:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
if ([picker sourceType] == UIImagePickerControllerSourceTypeCamera) {
// Do something with an image from the camera
} else {
// Do something with an image from another source
}
}
Run Code Online (Sandbox Code Playgroud)
在Swift3中:
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
if picker.sourceType == .camera {
// Do something with an image from the camera
}
else {
// Do something with an image from another source
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5557 次 |
| 最近记录: |