簡體   English   中英

從自定義相機中刪除取消按鈕

[英]Removing the cancel button from Custom camera

我在相機上使用自定義疊加框架。 在導航欄上,我在中間有app圖標,左邊有一個后退按鈕。

所以我想刪除捕獲按鈕旁邊的默認取消按鈕,但我不想刪除相機單擊按鈕。 我做過研究,但沒有找到完美的答案。 我已經使用了以下代碼,但它也刪除了單擊按鈕。

[picker setShowsCameraControls:YES];

我覺得你應該為你的uiimagepickercontroller添加自定義CameraOverlayView並隱藏CameraControls.This不會顯示你的取消按鈕。

 picker = [[UIImagePickerController alloc] init];                
 picker.delegate = self;
 picker.sourceType = UIImagePickerControllerSourceTypeCamera;
 [picker setShowsCameraControls:NO];
 CGRect screenBounds= [UIScreen mainScreen].bounds ;
 UIView *overlayView = [[UIView alloc] initWithFrame:screenBounds];
 [overlayView setAutoresizesSubviews:YES];
 [overlayView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin]; UIButton *captureButton=[[UIButton alloc]initWithFrame:CGRectMake(screenBounds.size.width/2-30, screenBounds.size.height-60,60 , 60)];
[captureButton addTarget:self action:@selector(captureImage:) forControlEvents:UIControlEventTouchUpInside];
[captureButton setBackgroundImage:[UIImage imageNamed:@"icon"] forState:UIControlStateNormal];
[overlayView addSubview:captureButton];
[picker setCameraOverlayView:overlayView];
[picker setCameraDevice:UIImagePickerControllerCameraDeviceRear];                
[self presentViewController:picker animated:YES completion:NULL];

這是Capture按鈕的動作。

-(void)captureImage:(UIButton*)sender
{
[picker takePicture];
}

並使用此委托方法來獲取圖像。

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [picker dismissViewControllerAnimated:YES completion:nil];
}

我認為你禁用但關於刪除我不確定,因為我知道這是不可能的,因為UIImagePickerController繼承UINavigationController。 那你就可以搞定

UINavigationBar *bar = picker.navigationBar;
[bar setHidden:NO];
bar.navigationItem.rightBarButtonItem = doneButton;

它僅適用於IOS 6

您可以使用此源ELCImagePickerController

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM