There is no view controller or any interfacebuilder, I want to build this with just code. I have the method setup where you can click on button to go to camera roll, but now I am lost on what to do next. I need a way to select an image and it will allow me to add the image to an image view. Any tips on what to do will be appreciated.
- (void)viewDidLoad {
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 100, 50)];
[self.view addSubview: imgView];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(aMethod)
forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[self.view addSubview:button];
}
-(void)aMethod{
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
picker.allowsImageEditing = YES;
[[self navigationController] presentModalViewController:picker animated:YES];
}
The previous answer was correct….but here is another way of looking at it….
As long as you have your code calling your photo album the next step you will need is:
That will place the returned info into your selected imageView…..
What you have in your posted code is opening your photo library….the net step is to say OK….Ive finished picking my media….what am I going to do with it?