Jam*_*LCQ 10 cocoa uitextview uitextviewdelegate ios
我正在尝试实现一个条款和条件页面的形式,其中"继续"按钮仅在用户滚动到UITextView的底部时启用.到目前为止,我已将我的类设置为UIScrollView委托并已实现以下方法:
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
NSLog(@"Checking if at bottom of UITextView");
CGPoint bottomOffset = CGPointMake(0,self.warningTextView.frame.size.height);
//if ([[self.warningTextView contentOffset] isEqualTO:bottomOffset])
{
}
}
Run Code Online (Sandbox Code Playgroud)
我已经评论了if语句,因为我不确定如何检查UITextView是否位于底部.
how*_*ghk 17
UITextView是一个UIScrollView子类.因此,使用UITextView时也可以使用您正在使用的UIScrollView委托方法.
scrollViewDidEndDecelerating您应该使用scrollViewDidScroll,而不是使用,因为滚动视图可能会停止滚动而不减速.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView.contentOffset.y >= scrollView.contentSize.height - scrollView.frame.size.height)
{
NSLog(@"at bottom");
}
}
Run Code Online (Sandbox Code Playgroud)
这个问题的 Swift 版本:
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView.contentOffset.y >= scrollView.contentSize.height - scrollView.frame.size.height {
print( "View scrolled to the bottom" )
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6250 次 |
| 最近记录: |