- (IBAction) useCamera: (id)sender { if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) { UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; imagePicker.mediaTypes = [NSArray arrayWithObjects: (NSString *) kUTTypeImage, nil]; imagePicker.allowsEditing = NO; [self presentModalViewController:imagePicker animated:YES]; newMedia = YES; } } -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [self.popoverController dismissPopoverAnimated:true]; NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; [self dismissModalViewControllerAnimated:YES]; if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; imageView.image = image; if (newMedia) UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:finishedSavingWithError:contextInfo:),nil); } } -(void)image:(UIImage *)image finishedSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { if (error) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Save failed" message: @"Failed to save image" delegate: self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; } } ) sender - (IBAction) useCamera: (id)sender { if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) { UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; imagePicker.mediaTypes = [NSArray arrayWithObjects: (NSString *) kUTTypeImage, nil]; imagePicker.allowsEditing = NO; [self presentModalViewController:imagePicker animated:YES]; newMedia = YES; } } -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [self.popoverController dismissPopoverAnimated:true]; NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; [self dismissModalViewControllerAnimated:YES]; if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; imageView.image = image; if (newMedia) UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:finishedSavingWithError:contextInfo:),nil); } } -(void)image:(UIImage *)image finishedSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { if (error) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Save failed" message: @"Failed to save image" delegate: self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; } } , nil); - (IBAction) useCamera: (id)sender { if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) { UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; imagePicker.mediaTypes = [NSArray arrayWithObjects: (NSString *) kUTTypeImage, nil]; imagePicker.allowsEditing = NO; [self presentModalViewController:imagePicker animated:YES]; newMedia = YES; } } -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [self.popoverController dismissPopoverAnimated:true]; NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; [self dismissModalViewControllerAnimated:YES]; if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; imageView.image = image; if (newMedia) UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:finishedSavingWithError:contextInfo:),nil); } } -(void)image:(UIImage *)image finishedSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { if (error) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Save failed" message: @"Failed to save image" delegate: self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; } } *) image - (IBAction) useCamera: (id)sender { if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) { UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; imagePicker.mediaTypes = [NSArray arrayWithObjects: (NSString *) kUTTypeImage, nil]; imagePicker.allowsEditing = NO; [self presentModalViewController:imagePicker animated:YES]; newMedia = YES; } } -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [self.popoverController dismissPopoverAnimated:true]; NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; [self dismissModalViewControllerAnimated:YES]; if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; imageView.image = image; if (newMedia) UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:finishedSavingWithError:contextInfo:),nil); } } -(void)image:(UIImage *)image finishedSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { if (error) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Save failed" message: @"Failed to save image" delegate: self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; } } ] - (IBAction) useCamera: (id)sender { if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) { UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; imagePicker.mediaTypes = [NSArray arrayWithObjects: (NSString *) kUTTypeImage, nil]; imagePicker.allowsEditing = NO; [self presentModalViewController:imagePicker animated:YES]; newMedia = YES; } } -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [self.popoverController dismissPopoverAnimated:true]; NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; [self dismissModalViewControllerAnimated:YES]; if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; imageView.image = image; if (newMedia) UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:finishedSavingWithError:contextInfo:),nil); } } -(void)image:(UIImage *)image finishedSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { if (error) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Save failed" message: @"Failed to save image" delegate: self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; } } " - (IBAction) useCamera: (id)sender { if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) { UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; imagePicker.mediaTypes = [NSArray arrayWithObjects: (NSString *) kUTTypeImage, nil]; imagePicker.allowsEditing = NO; [self presentModalViewController:imagePicker animated:YES]; newMedia = YES; } } -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [self.popoverController dismissPopoverAnimated:true]; NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; [self dismissModalViewControllerAnimated:YES]; if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; imageView.image = image; if (newMedia) UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:finishedSavingWithError:contextInfo:),nil); } } -(void)image:(UIImage *)image finishedSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { if (error) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Save failed" message: @"Failed to save image" delegate: self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; } }
source share