Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. #pragma mark - Add foto
  2. - (void)selectImage
  3. {
  4. __weak typeof(self) weakSelf = self;
  5. [self actionSheet_AddPhotoWithHandler:^(NSString *actionTitle) {
  6. if ( [actionTitle isEqualToString:@"Удалить фото"] )
  7. {
  8. // Очищаешь imageView.image
  9. }
  10. else if ( [actionTitle isEqualToString:@"Снять фото"] )
  11. {
  12. [weakSelf takePhoto];
  13. }
  14. else if ( [actionTitle isEqualToString:@"Выбрать имеющееся"] )
  15. {
  16. [weakSelf selectPhoto];
  17. }
  18. } content:@[@"Удалить фото", @"Снять фото", @"Выбрать имеющееся"]];
  19. }
  20.  
  21. - (void)takePhoto
  22. {
  23. UIImagePickerController *picker = [[UIImagePickerController alloc] init];
  24. picker.delegate = self;
  25. picker.allowsEditing = YES;
  26. picker.sourceType = UIImagePickerControllerSourceTypeCamera;
  27.  
  28. [self presentViewController:picker animated:YES completion:nil];
  29. }
  30.  
  31. - (void)selectPhoto
  32. {
  33. UIImagePickerController *picker = [[UIImagePickerController alloc] init];
  34. picker.delegate = self;
  35. picker.allowsEditing = YES;
  36. picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  37.  
  38. [self presentViewController:picker animated:YES completion:nil];
  39. }
  40.  
  41. #pragma mark - UINavigationControllerDelegate, UIImagePickerControllerDelegate
  42. - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
  43. {
  44. UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
  45.  
  46. [picker dismissViewControllerAnimated:YES completion:nil];
  47. }
  48.  
  49. - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
  50. {
  51. [picker dismissViewControllerAnimated:YES completion:nil];
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement