我正在开发UITableview从api加载更多数据。
-scrollViewDidScroll方法在我们第一次加载屏幕时调用,但在滚动或屏幕结束时调用。
我第一次加载屏幕时需要这个。
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
NSLog(@"calledee %d",page);
if (scrollView.contentOffset.y >= (scrollView.contentSize.height - scrollView.frame.size.height))
{
//mycode
}
}
答案 0 :(得分:0)
迅速4,5
private var firstLoad = true
// to avoid scrollViewDidScroll called when first time view controller load
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
firstLoad = false
}
// MARK: - UIScrollViewDelegate
extension ViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if firstLoad { return }
...
}
}