2015-09-14 1 views
8

カメラでカスタムオーバーレイフレームを使用しています。ナビゲーションバーには、中央にアプリアイコン、左に戻るボタンがあります。カスタムカメラからキャンセルボタンを削除する

キャプチャボタン以外のデフォルトのキャンセルボタンを削除したいと思いますが、カメラのクリックボタンを削除したくありません。私は研究をしましたが、完璧な答えは見つかりませんでした。私はすでに次のコードを使用していますが、クリックボタンも削除します。

[picker setShowsCameraControls:YES]; 

答えて

8

このソースを使用することができる唯一のIOS 6

のために動作します

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

を得ることができますし、私はあなたがあなたの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]; 

これは[キャプチャ]ボタンの操作です。

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

このデリゲートメソッドを使用してイメージを取得します。

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

ありがとう@deepesh。それは魅力のように働いた。 –

3

私はあなたが無効だと思うが、削除について、私はUIImagePickerControllerはUINavigationControllerを継承するので、それはできません知っていることを確認していません。あなたはそれはあなたがELCImagePickerController

+0

私はこれを試しましたが、動作しませんでした。 –

+0

IOS 6で動作しています。このライブラリを簡単に使用できます。https://github.com/B-Sides/ELCImagePickerController –