0
我對UIImagePickerController有疑問。我可以使用UIImagePickerController作爲預覽嗎?如果我這樣做,我必須隱藏記錄按鈕,有沒有辦法做到這一點?或任何其他方法來顯示除UIImagePickerController以外的預覽。隱藏UIImagePickerController中的記錄按鈕
感謝您的幫助...
我對UIImagePickerController有疑問。我可以使用UIImagePickerController作爲預覽嗎?如果我這樣做,我必須隱藏記錄按鈕,有沒有辦法做到這一點?或任何其他方法來顯示除UIImagePickerController以外的預覽。隱藏UIImagePickerController中的記錄按鈕
感謝您的幫助...
您可以通過使用隱藏UIImagePickerController
的控制:在圖像內看看這個代碼,它會隱藏所有的控件:
[myImagePickerController setShowsCameraControls:NO];
編輯選擇器允許您創建和添加自己的自定義控件。不幸的是,你不能有選擇地隱藏選擇器內的控件,所以這是另一種選擇。
- (void)showCamera
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
myImagePicker = [[UIImagePickerController alloc] init];
[myImagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[myImagePicker setDelegate:self];
[myImagePicker setShowsCameraControls:NO];
UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
UIButton *switchCameraButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[switchCameraButton setFrame:CGRectMake(10, 430, 72, 40)];
[switchCameraButton addTarget:self action:@selector(changeCamera:) forControlEvents:UIControlEventTouchUpInside];
[overlayView addSubview:switchCameraButton];
[myImagePicker setCameraOverlayView:overlayView];
[self presentViewController:myImagePicker animated:YES completion:nil];
}
}
- (IBAction)changeCamera:(id)sender
{
if (myImagePicker.cameraDevice == UIImagePickerControllerCameraDeviceFront) {
[myImagePicker setCameraDevice:UIImagePickerControllerCameraDeviceRear];
}else{
[myImagePicker setCameraDevice:UIImagePickerControllerCameraDeviceFront];
}
}
它會隱藏所有控件,我想允許用戶翻轉也.. – Newbee
@ user1587011請參閱我的編輯。您不能只隱藏其中一個控件,但可以隱藏它們並添加自己的自定義控件。 –