【问题标题】:how to find out the text in UITextview does not required to scroll in iOS如何在 UITextview 中查找文本不需要在 iOS 中滚动
【发布时间】:2021-05-08 09:27:01
【问题描述】:

我在 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 中的问题。

【问题讨论】:

  • 你搞定了吗?

标签: ios objective-c uiscrollview uitextview uitextviewdelegate


【解决方案1】:

例如,在viewDidLoad 中添加以下if 语句。 (假设你的UITextView在这里被称为textView

 if (self.textView.contentSize.height <= self.textView.frame.size.height) {
     // Enable the continue button.
 }

因为只有在内容可能完全可见时才会出现在此处。如果不需要,当然不会调用scrollViewDidScroll:

希望对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多