[英]WillDisplayFooterView UITableView does not execute
I set the delegate and datasource to self. 我将委托和数据源设置为self。 This is the code I want to run:
这是我要运行的代码:
func tableView(_ tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int) {
print("load")
}
This is how I added the footerView: 这就是我添加footerView的方式:
let footerView = UIView(frame: CGRect(x: 0, y: 0, width: table.frame.width, height: table.rowHeight))
let loader = NVActivityIndicatorView(frame: CGRect(x: 0, y: 0, width: table.frame.width, height: table.rowHeight), type: .ballScaleMultiple, color: .white)
loader.startAnimating()
loader.center = footerView.center
footerView.addSubview(loader)
table.tableFooterView = footerView
I can see the footerView, but "load" is never executed. 我可以看到footerView,但从未执行“加载”。 How can I be notified when the footerView is presented?
呈现footerView时如何通知我?
Try this 尝试这个
Objective C :- 目标C:-
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
static CGFloat lastY = 0;
CGFloat currentY = scrollView.contentOffset.y;
CGFloat headerHeight = self.headerView.frame.size.height;
if ((lastY <= headerHeight) && (currentY > headerHeight)) {
NSLog(@" ******* Header view just disappeared");
}
if ((lastY > headerHeight) && (currentY <= headerHeight)) {
NSLog(@" ******* Header view just appeared");
}
lastY = currentY;
}
Swift Version: 迅捷版:
func scrollViewDidScroll(_ scrollView: UIScrollView) {
var lastY: CGFloat = 0
let currentY: CGFloat = scrollView.contentOffset.y
let headerHeight: CGFloat? = headerView?.frame.size.height
if (lastY <= headerHeight) && (currentY > headerHeight) {
print(" ******* Header view just disappeared")
}
if (lastY > headerHeight) && (currentY <= headerHeight) {
print(" ******* Header view just appeared")
}
lastY = currentY
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.