swift 3 ios tableview scroll by cell

半城伤御伤魂 提交于 2021-02-08 07:25:23

问题


I created a tableview and it works normally as intended. However, I would like to change the scrolling such a way where the user can only scroll one cell at a time so that, there is never a time where the cell is cut in half..

This is an example: http://imgur.com/ffmk0jP

So basically i do not want the default scrolling.. i would like it to be scrolled one cell at a time to constantly remain with the view of the original state..

Is there a way?


回答1:


how about this ?

  1. scrollToNearestSelectedRowAtScrollPosition:animated:?

  2. tableview scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:NO];




回答2:


you can use viewWillTransition function for that to stop that issue..

verride func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator){}


来源:https://stackoverflow.com/questions/42712493/swift-3-ios-tableview-scroll-by-cell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!