swift UITableView scroll
swift UITableView begin scroll
How to know when UITableView did scroll to bottom in iPhone – Stack Overflow
Xcode中点击找到:
UITableViewDelegate
-》UIScrollViewDelegate
public protocol UIScrollViewDelegate : NSObjectProtocol { @available(iOS 2.0, *) optional public func scrollViewDidScroll(scrollView: UIScrollView) // any offset changes @available(iOS 3.2, *) optional public func scrollViewDidZoom(scrollView: UIScrollView) // any zoom scale changes // called on start of dragging (may require some time and or distance to move) @available(iOS 2.0, *) optional public func scrollViewWillBeginDragging(scrollView: UIScrollView) // called on finger up if the user dragged. velocity is in points/millisecond. targetContentOffset may be changed to adjust where the scroll view comes to rest @available(iOS 5.0, *) optional public func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) // called on finger up if the user dragged. decelerate is true if it will continue moving afterwards @available(iOS 2.0, *) optional public func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool) @available(iOS 2.0, *) optional public func scrollViewWillBeginDecelerating(scrollView: UIScrollView) // called on finger up as we are moving @available(iOS 2.0, *) optional public func scrollViewDidEndDecelerating(scrollView: UIScrollView) // called when scroll view grinds to a halt @available(iOS 2.0, *) optional public func scrollViewDidEndScrollingAnimation(scrollView: UIScrollView) // called when setContentOffset/scrollRectVisible:animated: finishes. not called if not animating @available(iOS 2.0, *) optional public func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? // return a view that will be scaled. if delegate returns nil, nothing happens @available(iOS 3.2, *) optional public func scrollViewWillBeginZooming(scrollView: UIScrollView, withView view: UIView?) // called before the scroll view begins zooming its content @available(iOS 2.0, *) optional public func scrollViewDidEndZooming(scrollView: UIScrollView, withView view: UIView?, atScale scale: CGFloat) // scale between minimum and maximum. called after any ‘bounce’ animations @available(iOS 2.0, *) 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 } |
最后用:
//will call multiple time during scroll // func scrollViewDidScroll(scrollView: UIScrollView){ // if self.inputMessageTextField.isFirstResponder() { // self.inputMessageTextField.resignFirstResponder() // } // } //only call once, when begin to scroll func scrollViewWillBeginDragging(scrollView: UIScrollView){ dismissKeyboard() } func dismissKeyboard(){ if self.inputMessageTextField.isFirstResponder() { self.inputMessageTextField.resignFirstResponder() } } |
即可实现:
开始滚动时,之前显示的键盘就消失了。
转载请注明:在路上 » [已解决]swift中判断UITableView开始滚动