Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try this~~ I think it is your goal.</p> <pre><code>#import "ViewController.h" @interface ViewController () @property (nonatomic, strong) UIImagePickerController *imagePicker; @end @implementation ViewController @synthesize imagePicker = _imagePicker; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:YES]; sleep(2); _imagePicker = [[UIImagePickerController alloc] init]; [_imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera]; [_imagePicker setDelegate:self]; UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(10, 50, 100, 30)]; [button setTitle:@"Library" forState:UIControlStateNormal]; [button setBackgroundColor:[UIColor darkGrayColor]]; [button addTarget:self action:@selector(gotoLibrary:) forControlEvents:UIControlEventTouchUpInside]; [_imagePicker.view addSubview:button]; [self presentViewController:_imagePicker animated:YES completion:nil]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(IBAction)gotoLibrary:(id)sender { UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; [imagePicker.view setFrame:CGRectMake(0, 80, 320, 350)]; [imagePicker setSourceType:UIImagePickerControllerSourceTypeSavedPhotosAlbum]; [imagePicker setDelegate:self]; [_imagePicker presentViewController:imagePicker animated:YES completion:nil]; } - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissViewControllerAnimated:YES completion:nil]; } - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { [picker dismissViewControllerAnimated:YES completion:nil]; } @end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload