How to make the UIView function like UIScrollView (Objective-C)

北城余情 提交于 2019-12-12 02:29:31

问题


I have a class named Topic. And inside that topic I can create (and delete) Messages. I need to show the messages in a view that can be scrolled/swiped either right or left (Right to show the older messages, and left to go back to the newer messages). Imagine an image collection that can be scrolled sideways in a ScrollView, that how this should look like. Since the messages is being add by the user, I can't use UIImage. I am thinking of the approach that I need to add use UIView instead of a ScrollView, now my problem is how can I make my UIView function as a ScrollView in terms of displaying data?

please help. Thanks.


回答1:


You should have to use gesture recognition. Check that user is swiping left or swiping right. after Identifying that you can change UIView with animation. I hope you can get me. This can be useful to you.




回答2:


You should be able to achieve what you want by enabling paging on the scroll view, by setting the following property to YES as shown:

scrollView.pagingEnabled = YES;

This will make the scroll view scroll one page at a time.



来源:https://stackoverflow.com/questions/17521176/how-to-make-the-uiview-function-like-uiscrollview-objective-c

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