我正在尝试实现一个类似于“条款和条件”页面的表单,其中“继续”按钮只有在用户滚动到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])
{
}
}
我已经注释掉if语句,因为我不确定如何检查UITextView是否在底部。
scrollView
是变量名,只要你也更改方法名称中的变量名即可随意更改。例如,你可以将其称为textView
,并将方法名称更改为- (void)scrollViewDidScroll:(UIScrollView *)textView
。或者,你可以直接引用你的 UITextView,并将 if 行更改为if (self.warningTextView.contentOffset.y >= self.warningTextView.contentSize.height - self.warningTextView.frame.size.height)
。 - howanghk