ModalViewController 加载在另一个 Modal 之上

发布于 2024-10-18 09:30:10 字数 1233 浏览 6 评论 0原文

可能有更好的方法来做到这一点,如果有请指导我。

我正在创建一个 UIImagePickerController ,它在 viewDidAppear 中带有一个overlayView,用于“从库中选择”、“拍照”、“闪光灯”“相机源”等。

// Set up the camera
imagePicker = [[UIImagePickerController alloc] 
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;

imagePicker.cameraOverlayView = [self cameraOverlayView];
cameraOverlayView.backgroundColor = [UIColor clearColor];
imagePicker.showsCameraControls = NO;
imagePicker.toolbarHidden = YES;

imagePicker.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:imagePicker animated:YES]; 

然后我有一个 IBAction 调用我的“选择”从库函数',加载另一个 UIImagePickerController 以从设备中选择照片。

- (IBAction)library:(id)sender
{
    UIImagePickerController *libraryPicker = [[[UIImagePickerController alloc] init] autorelease];

    libraryPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    libraryPicker.delegate = self;

    [self.imagePicker presentModalViewController:libraryPicker animated:YES];
}

当出现“从库中选择”模式时,我会在顶部看到一个大约状态栏大小的白色条。我知道这与在模态之上叠加模态有关,但我不知道如何解决它。 (即,我的“拍照”视图布局导航良好,尽管不显示额外的“从库中选择”模式)。

有什么想法吗?任何帮助或指导将不胜感激!

There may be a better way to do this, and please direct me if there is.

I'm creating an UIImagePickerController with an overlayView in viewDidAppear for 'choose from library', 'take photo', 'flash' 'camera source', etc.

// Set up the camera
imagePicker = [[UIImagePickerController alloc] 
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;

imagePicker.cameraOverlayView = [self cameraOverlayView];
cameraOverlayView.backgroundColor = [UIColor clearColor];
imagePicker.showsCameraControls = NO;
imagePicker.toolbarHidden = YES;

imagePicker.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:imagePicker animated:YES]; 

I then have an IBAction that calls my 'choose from library function', loading another UIImagePickerController to choose a photo from the device.

- (IBAction)library:(id)sender
{
    UIImagePickerController *libraryPicker = [[[UIImagePickerController alloc] init] autorelease];

    libraryPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    libraryPicker.delegate = self;

    [self.imagePicker presentModalViewController:libraryPicker animated:YES];
}

I'm getting a white bar across the top about the size of a status bar when the 'choose from library' modal is presented. I know it has something to do with overlaying a modal on top of a modal, but I don't know how to solve it. (IE, my view layout for 'take photo' navigates fine, although doesn't display the additional 'choose from library' modal).

Any ideas? Any help or direction would be greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

︶ ̄淡然 2024-10-25 09:30:10

尝试

[self presentModalViewController:libraryPicker animated:YES];

代替

[self.imagePicker presentModalViewController:libraryPicker animated:YES];

Try

[self presentModalViewController:libraryPicker animated:YES];

Instead of

[self.imagePicker presentModalViewController:libraryPicker animated:YES];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文