2013-11-26 72 views
6

我試圖在相機視圖(UIImagePickerController)上顯示庫按鈕。這裏是我的代碼: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]; 
} 

問題是在圖片,當我嘗試拍照時。我拍照時如何隱藏圖庫按鈕? How it looks like

And problem as this

+0

嗨,你能解決這個問題嗎? –

+0

加入問題 – Danpe

回答

0

這個可憐的人的方式來解決這個問題,將標籤在頂部位置,居中,所以它不會與照片按鈕衝突;)

不是最大的修復 - 但它的超級快速

相關問題