iOS 5 问题:拉出 UITextView 时键盘消失

发布于 2024-12-18 03:59:48 字数 1076 浏览 4 评论 0原文

我在应用程序商店中有一个不错的小应用程序,它本身就运行得很好。在 iOS 5 到来之前,生活一直很美好。现在,我的应用程序出现了一些无法修复的问题,因为我不知道发生了什么,因为我觉得它们是 iOS 5 的问题,而不是我的问题。

我错过了 iOS 5 转换手册吗?或者他们只是为了好玩而改变一切,并希望我们找出所有的复活节彩蛋在哪里?

这是我遇到的一个问题(我浪费了很多时间试图解决),当我只是说我想在良好的 ol' 4.2 中运行应用程序时,这个问题根本不存在:

键盘消失< /strong>

因此,当我拉出一个简单的模态视图时,我选择一个 tableView 单元格,然后呈现一个 textView 以便用户可以输入一些文本。当textView变得可见时,我调用[textView变成FirstResponder];以便键盘启动并可供用户使用。这是第一次。然后,当您关闭 modalView (并收到我上面提到的奇怪错误),然后尝试返回到 modalView 并拉起 textView 时,键盘飞走了!你只看到它不到一秒钟,然后噗的一声它就消失了。我有一个文本视图,我的光标处于活动状态并且我正在尝试编辑,但我的键盘拒绝显示。再说一遍,这在 4.2 中工作得很好,但在 5 中就不行了!

我已经尝试了一切方法来解决这些问题,但就是无法让它们发挥作用。我应该怎么办?我觉得这些是操作系统方面的错误,不是我的!

感谢您的帮助。

编辑:

更清楚地说,我将回顾一下我试图通过视图层次结构完成的任务。当我显示模式视图时,我有两个不同的单元格,其中填充了一些文本。第二个单元格应该是可编辑的,因此当用户点击该单元格时,我取消隐藏在 viewDidLoad 上隐藏的 UITextView,并调用 [textViewBecomeFirstResponder];在textView上,它工作得很好。 textView 是可编辑的,当键盘关闭时,它会隐藏并更新相应的单元格内容。

问题是,当我关闭模态视图,然后返回模态视图,并选择可编辑单元格时,textView 显示得很好,并且可以编辑,但键盘会闪烁到屏幕上,然后飞走并获胜不显示。所以我有我的 textView 并可编辑,但尽我所能,键盘不会显示!这绝对让我抓狂,尤其是因为它在 iOS 4.2 上完美运行。

I have a nice little app on the app store that does pretty well for itself. Life was great until iOS 5 came to town. Now, I have a number of issues with my app that I have no way of fixing because I have no clue what is going on, because I feel that they are iOS 5 issues, not mine.

Was there an iOS 5 conversion manual I missed? Or did they just change everything for fun, and want us to figure out where all the easter eggs were?

Here is an issue I am experiencing (that I have wasted so much time trying to fix), that DON'T EXIST AT ALL when I simply say that I want to run the app in good ol' 4.2:

Disappearing keyboard

So when I pull up a simple modal view, I select a tableView cell, and then I present a textView so that users can enter some text. When the textView becomes visible, I call [textView becomesFirstResponder]; so that the keyboard is up and ready for the user to use. This works the first time. Then, when you dismiss the modalView (and get the weird error I just mentioned above), and then try and go back into the modalView, and pull up the textView, the keyboard flies away! You see it for a fraction of a second, and then POOF it's gone. I have a textView upon which my cursor is active and I am trying to edit, but my keyboard refuses to show up. Again, this works perfectly in 4.2, but not in 5!

I have tried everything under the sun to get these issues worked out, but I just can't get them working. What should I do? I feel that these are bugs on the OS side, not mine!

Thanks for your help.

Edit:

To be more clear, I will go over what I am trying to accomplish with my view hierarchy. When I display my modal view, I have two different cells that I fill up with some text. The second cell is supposed to be editable, so when the user taps the cell, I unhide a UITextView that I hid on viewDidLoad, and call [textView becomeFirstResponder]; on the textView, and it works fine. The textView is editable, and it hides and updates the appropriate cell content when the keyboard is dismissed.

The problem is that when I dismiss the modal view, then came back into the modal view, and select the editable cell, the textView shows up just fine, and it is editable, but the keyboard blips onto the screen but then flys away and won't show. So I have my textView there and editable, but try as I might, the keyboard won't show! It's absolutely driving me nuts, especially because it works perfectly on iOS 4.2.

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

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

发布评论

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

评论(3

゛清羽墨安 2024-12-25 03:59:48

我觉得这与您呈现和忽略模态视图的方式有关。苹果推出了一种新的观点呈现方法。您可以尝试使用这些而不是旧的,看看它是否可以解决您的问题。

因此,您要做的就是:

将此方法:更改

presentModalViewController:animated:

为 iOS 5 引入的新首选方法:

presentViewController:animated:completion:

根据您是否使用 dismissModalViewControllerAnimated: 来关闭视图,将其更改为 dismissViewControllerAnimated:completion< /代码>。

此方法还具有完成处理程序,这对于在呈现/关闭视图后执行一些额外工作非常有用。也许这也有助于解决您的其他问题。让我知道这是否有帮助。

I have the feeling it has something to do with the way you present and dismissing the modalview. Apple introduced a new method to present views. May you try using theses instead of the old ones and see if it fixes your problem.

So here is what you do:

change this method:

presentModalViewController:animated:

into the new preferred method introduced with iOS 5:

presentViewController:animated:completion:

Depending if you are using dismissModalViewControllerAnimated:to dismiss your view, change it into dismissViewControllerAnimated:completion.

This methods also have completion handler which is very useful to do some extra work after the view has been presented/dismissed. Maybe that also helps with your other issue. Let me know if that might helped.

在梵高的星空下 2024-12-25 03:59:48

我刚刚在苹果开发者网站 此页面上发现。我不知道这是否正确,但有一些名为“iOS 4.x API diffs”的文档。似乎是 4.x 到 5.x 的差异列表。希望这能有所帮助。再见

i just found out on Apple's developers website this page. I don't know exactly if it's the right thing but there are some documents called "iOS 4.x API diffs". Seems to be a list of differences from 4.x to 5.x. Hope this can help. Bye

吾家有女初长成 2024-12-25 03:59:48

好吧,我刚刚能弄清楚大火中发生了什么。我将 shouldAutorotateToInterfaceOrientation 值设置为 BOOL 变量,该变量可以从 TURE 或 FALSE 更改,这样当 modalView 返回时,就会出现它有可能不知道状态栏的状态/大小。通过手动将其设置为 TRUE,它解决了问题,问题就消失了。

Ok, I was just able to figure out what in the blazes was going on. I had the shouldAutorotateToInterfaceOrientation value set to a BOOL variable that could change from TURE or FALSE, so that when the modalView was coming back, there was a chance that it didn't know the state/size of the status bar. By manually setting it to TRUE, it fixed the issue, and the problem disappeared.

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