iPhone UIImagePickerController 将内容下推

发布于 2024-09-26 22:55:08 字数 517 浏览 0 评论 0原文

我目前正在开发一个非常简单的 iPhone 应用程序。我有一个 UIWebView,其底部有一个 UIToolBar,上面有一个按钮。我已经通过代码构建了它,尽管我确实创建了一个空的 NIB,因为我希望 Facebook Connect 最终能够使用它,并且当我过去没有使用这个空的 NIB 设置它时遇到了问题......

我添加了另一个按钮,该按钮位于页面中间(用于构建时的测试目的),该按钮调用 UIActionSheet。当您选择 UIActionSheet 上的按钮时,我会在所有内容之上弹出 UIImagePickerController,以便从我的相机胶卷中选择图像。

问题是,当我的 UIImagePickerController 关闭时(通过选择图像或按取消按钮),页面上的所有内容都被下推了 20 像素...

虽然我确实可以将我所有元素的框架都增加了 20 像素,这感觉很“hacky”,虽然我喜欢 hack,但我宁愿弄清楚为什么会发生这种情况。

有人遇到过这种情况吗?你是怎么修好的?

谢谢你,

--d

I'm working on a pretty simple iPhone app at the moment. I have a UIWebView with a UIToolBar at the bottom of it with a button on it. I've built it all through code, although I did create an empty NIB as I am hoping to get Facebook Connect working with it eventually and have had problems when I don't set it up with this empty NIB in the past...

I've added another button that just kind of sits in the middle of the page (for testing purposes while I build) that calls a UIActionSheet. When you select a button on the UIActionSheet, I have the UIImagePickerController popping up on top of everything, in order to select an image from my Camera Roll.

The problem is that when my UIImagePickerController has closed (either by selecting an image or by pressing the cancel button), all of the content on my page has been pushed down by 20 pixels...

While it is true that I could just shift the frames of all of my elements up by 20 pixels, that feels "hacky", and while I love to hack, I'd rather figure out why this is going on.

Has anyone ever encountered this? How did you fix it?

Thank you,

--d

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

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

发布评论

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

评论(3

半衾梦 2024-10-03 22:55:08

您的应用程序是全屏应用程序吗? UIImagePickerController 使状态栏出现。使关闭 UIImagePickerController 的方法也隐藏状态栏。

Is your app a full screen app? UIImagePickerController makes the status bar appear. Make the method that dismisses UIImagePickerController hide the status bar also.

惯饮孤独 2024-10-03 22:55:08

我在使用 MFMailComposeViewController 时遇到类似的问题。当我关闭它时,它会导致屏幕向下移动 20 像素。

我猜这和IB有关,因为我的IB最近有点不对劲。它认为在我看来有一个状态栏,即使没有指定。在找到正确的解决方案之前,我将使用 CGRectMake 来“修复”问题。

我将以下代码放在 didFinishWithResult 方法的底部。这是我关闭 MFMailComposeViewController 时调用的方法。当您关闭 UIImagePickerController 时,您可能可以放置相同的代码。

self.view.frame = CGRectMake(0, 0, 320, 480);

如果您找到正确的解决方案,我很想知道:)

I'm having a similar issue with using the MFMailComposeViewController. When I dismiss it it causes the screen to move down 20 pixels.

I'm guessing it has something to do with IB, as mine has been acting up a bit recently. It thinks there is a status bar in my view even though there are none specified. Until I find the proper solution I'm using CGRectMake to 'fix' the problem.

I place the following code at the bottom of the didFinishWithResult method. This is the method called when I dismiss the MFMailComposeViewController. You could probably place the same code when you dismiss the UIImagePickerController.

self.view.frame = CGRectMake(0, 0, 320, 480);

if you find out the proper solution id love to know it :)

挥剑断情 2024-10-03 22:55:08

在viewWillAppear中将navigationController.view.frame设置为CGRectMake(0, 0, 320, 460)。如果您支持横向,那么在横向模式下您将需要执行 CGRectMake(0, 0, 480, 300) 。

祝你好运!

Set the navigationController.view.frame to CGRectMake(0, 0, 320, 460) in viewWillAppear. If you support landscape, then you will need to do CGRectMake(0, 0, 480, 300) if you are in landscape mode.

Good luck!

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