UIImagePickerController以简单的方式在相机中显示库按钮

use*_*077 6 uiimagepickercontroller ios

我想在相机视图上显示库按钮(UIImagePickerController).这是我的代码:

- (void)takePhoto{
    _imagePicker = [[UIImagePickerController alloc] init];
    [_imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
    [_imagePicker setDelegate:self];
    _imagePicker.allowsEditing = YES;
    CGRect frame = self.view.frame;
    int y = frame.size.height;
    int x = frame.size.width;

    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(x-100, y-50-1, 100, 30)];
    [button setTitle:@"Library" forState:UIControlStateNormal];
    [button setBackgroundColor:[UIColor clearColor]];
    [button addTarget:self action:@selector(gotoLibrary:) forControlEvents:UIControlEventTouchUpInside];

    [_imagePicker.view addSubview:button];

    [self presentViewController:_imagePicker animated:NO completion:nil];


}
-(IBAction)gotoLibrary:(id)sender
{
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    [imagePicker.view setFrame:CGRectMake(0, 80, 450, 350)];
    [imagePicker setSourceType:UIImagePickerControllerSourceTypeSavedPhotosAlbum];
    imagePicker.allowsEditing = YES;
    [imagePicker setDelegate:self];

    [_imagePicker presentViewController:imagePicker animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)

当我尝试拍照时问题在于图像.拍照时如何隐藏图书馆按钮? 看起来如何

和问题一样

Sha*_*ssy 0

解决这个问题的可怜方法是将标签放置在顶部居中,这样它就不会与照片按钮冲突;)

不是最好的解决方案 - 但它超级快