提问人:Rakesh 提问时间:2/4/2021 最后编辑:Rakesh 更新时间:2/5/2021 访问量:260
如何在 UI 中查找文本在 iOS 中不需要滚动
how to find out the text in UITextview does not required to scroll in iOS
问:
我在 UITextView 中显示条款和条件。当用户到达 UITextView 中文本的最后一行时,然后仅启用屏幕底部可用的按钮(导航到下一个屏幕)。
我已经使用文本视图委托实现了所需的逻辑。
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
float scrollViewHeight = scrollView.frame.size.height;
float scrollContentSizeHeight = scrollView.contentSize.height;
float scrollOffset = scrollView.contentOffset.y;
if (scrollOffset + scrollViewHeight == scrollContentSizeHeight)
{ // login to enable the button
}
}
此逻辑工作正常,但在ipad Pro设备中,这会导致麻烦。ipad pro 屏幕很大,所有文本都无需滚动即可看到。
如何在没有滚动的情况下在 UITextView 中查找文本。还有如何处理ipad Pro中的问题。
答:
1赞
Jim Tierney
2/4/2021
#1
例如,在 example 中添加以下语句。
(假设这里叫你)if
viewDidLoad
UITextView
textView
if (self.textView.contentSize.height <= self.textView.frame.size.height) {
// Enable the continue button.
}
因为只有当内容可能完全可见时,这才会落在这里。由于不需要,当然不被调用。scrollViewDidScroll:
希望这会有所帮助
评论