2011-08-23 86 views

回答

50

因爲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 
    } 
} 
8

在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 
    } 

    } 
+1

在雨燕3.0,它現在'picker.sourceType == .camera',因爲'.Camera'已被替換爲'.camera'。其他值是'.photoLibrary'和'.savedPhotosAlbum'。 HTH – duthen

相關問題