gpt4 book ai didi

iphone - 在 iPhone App 中将焦点设置在 textView

转载 作者:搜寻专家 更新时间:2023-10-30 19:40:36 24 4
gpt4 key购买 nike

在我的 iPhone 应用程序中,我同时放置了 textField 和 TextView我用 scrollview 将它们分组

现在的问题是我打电话的时候

[textField becomeBecomeFirstResponder]; 

它将焦点设置在 scrollView 中的 textField 上,并相应地使 content Area 在 scrollView 中可见

但是当我对 UItextView 做同样的事情时:

[textView becomeBecomeFirstResponder]; 

它不会使 TextView 在 ScrollView 中可见,即它不会专注于 textView(光标设置在 TextView 上,但 ScrollView 的内容区域不会在没有手动滚动的情况下出现)

我应该怎么做才能将焦点设置在 textView 上并在 scrollview 中相应地设置内容区域?

最佳答案

我相信你的问题在于 UITextView 是一个 UIScrollView,而 UITextField 是一个 UIControl。

很有可能,虽然我目前还没有在代码中对此进行测试,但处理此问题的最佳方法很可能是观察 textView.isFirstResponder 并在为真时调用 [ scrollView scrollRectToVisible:textView.frame animated:YES] 在你的 UIScrollView 上。

关于iphone - 在 iPhone App 中将焦点设置在 textView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5335093/

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