Reputation: 41
How do I add button and select photo. Please help and tell me how to solve
Upvotes: 2
Views: 2596
Reputation: 895
You need to create a CustomOverlayView. Then Config your picker something like this:
overlay = [[CustomOverlayView alloc]initWithFrame:self.view.bounds];
overlay.delegate = self;
picker = [[UIImagePickerController alloc]init];
picker.delegate = self;
picker.navigationBarHidden = YES;
picker.toolbarHidden = YES;
picker.wantsFullScreenLayout = YES;
picker.allowsEditing = YES;
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]){
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else{
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
picker.showsCameraControls = NO;
picker.cameraOverlayView = overlay;
Upvotes: 2
Reputation: 13
This will work:
- (void)showImagePicker:(UIImagePickerControllerSourceType)source{
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
imgPicker.sourceType = source;
imgPicker.delegate = self;
[self presentModalViewController:ipc animated:YES];
}
The button pressed action:
- (IBAction)chooseImage:(id)sender {
[self showImagePicker:UIImagePickerControllerSourceTypePhotoLibrary];
}
And do this:
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissViewControllerAnimated:YES completion:nil];
}
Or perform this code by the right actions
Upvotes: -1