Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Select Image from Device

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 161
    Comment on it

    Hi,
    If you want to select image from device in Xcode, you can use the below code for this.

    #import <uikit.h>
    @interface ViewController : UIViewController&lt;UIImagePickerControllerDelegate,UINavigationControllerDelegate&gt;
    {
    
    _weak IBOutlet UIButton *ImageButton;
      _weak IBOutlet UIImage *image;
    }
    
    @property (strong,nonatomic) IBOutlet UIImageView *imageView;
    
    
    -(IBAction)selectPhoto:(UIButton *)sender;
    -(IBAction)takePhota:(UIButton *)sender;
    
    
    
    @end
    
    #import "ViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
    }
    
    - (IBAction)selectPhoto:(UIButton *)sender {
    
        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
        picker.allowsEditing = YES;
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    
        [self presentViewController:picker animated:YES completion:NULL];
    
    
    }
    
    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {
        UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
        self.imageView.image = chosenImage;
    
        [picker dismissViewControllerAnimated:YES completion:NULL];
    
        }
    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    
    
        [picker dismissViewControllerAnimated:YES completion:NULL];
    }
    
    
    
    @end
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: