![](/img/trans.png)
[英]Add admob view to the top or bottom of a UITableView programmatically?
[英]Add a top view to UITableview and scroll it to bottom of navigationbar
我已经创建了一个视图并将其添加到UITableview的子视图中-
topView = UIView(frame: CGRectMake(0, 250, self.myTableView.frame.width, 44))
topView.backgroundColor = UIColor.redColor()
self.view.addSubview(topView)
self.view.bringSubviewToFront(topView)
self.myTableView.contentInset = UIEdgeInsetsMake(294, 0, 0, 0)
现在,我想将此视图滚动到navigationBar
的底部,因此我编写了scrollview
delegete方法-
func scrollViewDidScroll(scrollView: UIScrollView){
var rect:CGRect = topView.frame;
if myTableView.contentOffset.y <= -98 {
rect.origin.y = (myTableView.contentOffset.y * -1) - rect.size.height
topView.frame = rect
}
}
=>在这里尝试以下代码。
UIView *myProgView = (UIView *)self.progView; //progView is a method that returns a UIView
[self.tableView insertSubview:myProgView aboveSubview:self.tableView];
[self.tableView bringSubviewToFront:myProgView];
=>做tableView滚动位置:
if numberOfRows > 0 {
let indexPath = NSIndexPath(forRow: numberOfRows-1, inSection: (numberOfSections-1))
self.tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: UITableViewScrollPosition.Bottom, animated: animated)
}
现在,我可以将所需的视图滚动到tableview部分。
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.