-(IBAction)addPicEvent
{
UIImagePickerControllerSourceType sourceType=UIImagePickerControllerSourceTypeCamera;
if (![UIImagePickerControllerisSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
}
UIImagePickerController * picker = [[UIImagePickerControlleralloc]init];
picker.delegate=self;
picker.allowsEditing=YES;
picker.sourceType=sourceType;
[selfpresentModalViewController:picker animated:YES];
}
-(void)saveImage:(UIImage*)image
{
NSLog(@"儲存");
}
-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissModalViewControllerAnimated:YES];
UIImage * image=[info objectForKey:UIImagePickerControllerEditedImage];
[selfperformSelector:@selector(saveImage:) withObject:image afterDelay:0.5];
}
-(void)imagePickerControllerDIdCancel:(UIImagePickerController*)picker
{
[picker dismissModalViewControllerAnimated:YES];
}
摘自 凡娃軟體