gpt4 book ai didi

ios - 使用 UIPresentationFormSheet,为什么我的 View 在键盘启动时不会移动到键盘上方?

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:18:07 27 4
gpt4 key购买 nike

苹果说:

UIModalPresentationFormSheet The width and height of the presented view are smaller than those of the screen and the view is centered on the screen. If the device is in a landscape orientation and the keyboard is visible, the position of the view is adjusted upward so that the view remains visible. All uncovered areas are dimmed to prevent the user from interacting with them.

但是当键盘可见时,我的 View 不会向上移动。我基本上想在键盘上方以模态方式呈现 TextView ,以便用户可以输入文本,然后点击发送(在呈现 View 的导航栏按钮中。)

我的呈现 View 是一个 UISplitViewController(不是它的 subview 之一),我呈现的是 UINavigationController,它的顶层 View Controller 基本上是一个 UITextView。旋转有效,但呈现的 View 在两个方向上都被键盘重叠。

我找到了 some questions asking在这种情况下如何调整呈现 View 的大小,这很好,但我不想通过在演示者或呈现 View 中手动调整大小来做出假设。似乎它应该只选择一个合适的(未记录的)尺寸,只需在键盘显示时自动将其向上移动即可。

我的演示代码如下所示:

MyViewController *vc = [[MyViewController alloc] init];
UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease];
nav.modalPresentationStyle = UIModalPresentationFormSheet;
[self.splitViewController presentModalViewController:nav animated:YES];

最佳答案

当我完成我的问题时,我意识到我正在 viewWillAppear 中的 UITextView 上调用 becomeFirstResponder。如果您将其更改为 viewDidAppear,它将起作用,这是有道理的。

关于ios - 使用 UIPresentationFormSheet,为什么我的 View 在键盘启动时不会移动到键盘上方?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7932595/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com