[英]Add a top view to UITableview and scroll it to bottom of navigationbar
I Have created a view and added to subview of UITableview - 我已经创建了一个视图并将其添加到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)
Now I want to scroll this view to the bottom of navigationBar
so I have written scrollview
delegete method- 现在,我想将此视图滚动到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
}
}
=> Here try following code.. =>在这里尝试以下代码。
UIView *myProgView = (UIView *)self.progView; //progView is a method that returns a UIView
[self.tableView insertSubview:myProgView aboveSubview:self.tableView];
[self.tableView bringSubviewToFront:myProgView];
=> do tableView Scroll position : =>做tableView滚动位置:
if numberOfRows > 0 {
let indexPath = NSIndexPath(forRow: numberOfRows-1, inSection: (numberOfSections-1))
self.tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: UITableViewScrollPosition.Bottom, animated: animated)
}
Now i am able to scrolling my desired view into the tableview section. 现在,我可以将所需的视图滚动到tableview部分。
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.