TableView之ScrollView爱恨

在使用TableView时,我们常常不需要特殊的设置滚动,就能非常轻松的实现基本的滚动效果。但是常常一些特殊的情况,我们必须重新设置TableView。

在设置TableView的滚动效果时,我们需要重写ScrollView的Delegate方法。


public func scrollViewDidScroll(scrollView: UIScrollView) // any offset changes

   

    public func scrollViewDidZoom(scrollView: UIScrollView) // any zoom scale changes

    

    // called on start of dragging (may require some time and or distance to move)

   

    optional public func scrollViewShouldScrollToTop(scrollView: UIScrollView) -> Bool // return a yes if you want to scroll to the top. if not defined, assumes YES

    @available(iOS 2.0, *)

    optional public func scrollViewDidScrollToTop(scrollView: UIScrollView) // called when scrolling animation finished. may be called immediately if already at top


ScrollView中的一些方法并没有全部写上去,根据需求去设置不同的代理方法。


TableView的其它的小细节

tableview 选中一行后,不显示选中颜色,不要将tableview的allowsSelection设置成NO,那样的话可能导致tableview不能响应点击动作。合理的解决方法是:cell.selectionStyle = UITableViewCellSelectionStyleNone;


猜你喜欢

转载自blog.csdn.net/Future_One/article/details/51885374
今日推荐