Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma mark - Add foto
- - (void)selectImage
- {
- __weak typeof(self) weakSelf = self;
- [self actionSheet_AddPhotoWithHandler:^(NSString *actionTitle) {
- if ( [actionTitle isEqualToString:@"Удалить фото"] )
- {
- // Очищаешь imageView.image
- }
- else if ( [actionTitle isEqualToString:@"Снять фото"] )
- {
- [weakSelf takePhoto];
- }
- else if ( [actionTitle isEqualToString:@"Выбрать имеющееся"] )
- {
- [weakSelf selectPhoto];
- }
- } content:@[@"Удалить фото", @"Снять фото", @"Выбрать имеющееся"]];
- }
- - (void)takePhoto
- {
- UIImagePickerController *picker = [[UIImagePickerController alloc] init];
- picker.delegate = self;
- picker.allowsEditing = YES;
- picker.sourceType = UIImagePickerControllerSourceTypeCamera;
- [self presentViewController:picker animated:YES completion:nil];
- }
- - (void)selectPhoto
- {
- UIImagePickerController *picker = [[UIImagePickerController alloc] init];
- picker.delegate = self;
- picker.allowsEditing = YES;
- picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
- [self presentViewController:picker animated:YES completion:nil];
- }
- #pragma mark - UINavigationControllerDelegate, UIImagePickerControllerDelegate
- - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
- {
- UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
- [picker dismissViewControllerAnimated:YES completion:nil];
- }
- - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
- {
- [picker dismissViewControllerAnimated:YES completion:nil];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement