gpt4 book ai didi

ios - 禁用重拍、播放和使用视频画面 UIImagePickerController

转载 作者:可可西里 更新时间:2023-11-01 03:52:02 25 4
gpt4 key购买 nike

我只想要一个屏幕: enter image description here使用 UIImagePickerController 时,它使用两个屏幕。

但我不想要这个:

enter image description here

这可能吗?

最佳答案

@Fahri 是对的 AVFoundation 更灵活但是如果你想坚持使用 UIImagePickerController 你可以做的是关闭相机控制通过将 showsCameraControls 属性设置为 NO,然后呈现您自己的 View 和自定义方法。

将您的代码更改为:

拍摄视频

- (IBAction)takeVideo:(UIButton *)sender {

UIToolbar *toolBar=[[UIToolbar alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height-54, self.view.frame.size.width, 55)];

toolBar.barStyle = UIBarStyleBlackOpaque;
NSArray *items=[NSArray arrayWithObjects:
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelVideo)],
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(shootVideo)],
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
nil];
[toolBar setItems:items];

// create the overlay view
UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-44)];
overlayView.opaque=NO;
overlayView.backgroundColor=[UIColor clearColor];

// parent view for our overlay
UIView *cameraView=[[UIView alloc] initWithFrame:self.view.bounds];
[cameraView addSubview:overlayView];
[cameraView addSubview:toolBar];

picker = [[UIImagePickerController alloc] init];

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO){
NSLog(@"Camera not available");
return;
}

picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
picker.delegate = self;

// hide the camera controls
picker.showsCameraControls=NO;
[picker setCameraOverlayView:cameraView];

[self presentViewController:picker animated:YES completion:nil];

}

拍摄视频

-(void) shootVideo {
[picker startVideoCapture];
}

取消视频

- (IBAction)cancelVideo {
[self dismissViewControllerAnimated:YES completion:nil];
}

截图

enter image description here

DOWNLOAD DEMO PROJECT

关于ios - 禁用重拍、播放和使用视频画面 UIImagePickerController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23427545/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com