UITableView in UIScrollview scrolling delay

[亡魂溺海] 提交于 2019-12-12 10:26:29

问题


I have a UIScrollView and I am adding many viewcontrollers having UITableView in it on that scrollview,Actually my requirement is that when I scroll horizontally on screen it will switch to next content.Now when I scroll the table vertically and then swipe horizontally it does not scroll horizontally until table stops scrolling vertically.

Please help if you have any suggestion


回答1:


You could use UIScrollViewDelegate methods. E.g. scrollViewDidEndDecelerating: and scrollViewDidEndDragging:willDecelerate: to know when your vertical scrolling is finished.

If it's enough for you to just lock the horizontal scrolling while performing the vertical one, then you can do the lock on the start of vertical scrolling (e.g. in scrollViewDidScroll) and unlock horizontal scrolling when finished (see the methods above) with vertical. Also you can take a look at this topic where different solutions are proposed.

P.S. To disable horizontal scrolling, but to leave the vertical, you can for example change scrollview's contentsize as described here.

Hope this helps.



来源:https://stackoverflow.com/questions/16932204/uitableview-in-uiscrollview-scrolling-delay

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