问题
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