我正在尝试设置一个包含 UIImagePickerControllerView 顶部按钮的视图。我已经看到可以构建一个overlayView 视图设置picker.showsCameraControls = NO;
并将子视图添加到Overlay。但我不想丢失控制器,只是在顶部添加一个按钮。这可能吗?
这是我的代码:
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *imagePickerCam =
[[UIImagePickerController alloc] init];
imagePickerCam.delegate = self;
imagePickerCam.sourceType =
UIImagePickerControllerSourceTypeCamera;
imagePickerCam.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeMovie,
nil];
imagePickerCam.allowsEditing = NO;
UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
UIButton *Button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[Button setFrame:CGRectMake(200, 480, 80, 80)];
[Button addTarget:self action:@selector(action:) forControlEvents:UIControlEventTouchUpInside];
[overlayView addSubview:Button];
[imagePickerCam.view addSubview:overlayView];
[overlayView bringSubviewToFront:imagePickerCam.view];
[self presentModalViewController:imagePickerCam
animated:YES];
}
我正在尝试这个:
[imagePickerCam.view addSubview:overlayView];
[overlayView bringSubviewToFront:imagePickerCam.view];
当然,它不起作用。任何想法?