How do you make UIView's slide left to right and being butted right up against each other in iPhone?
I've seen apps that have views that you swipe and it just 开发者_如何学Pythonslides to the next one, and it moves according to how far you've swiped. Kind of like a film strip. Is there an easy way to do this?
You can use a UIScrollView to achieve precisely this effect. (Each "picture" in the film strip being a view that you add to the scroll view.)
Incidentally, the above linked class reference document also contains links to sample code - see the "Related sample code" section in the header.
UPDATE
Here's some sample code to detect the "current" page. It's been a while since I've used a UIScrollView (this is from an early "getting to know iOS" plaything I wrote), so this may not be the best solution.
// Calculate which page is visible
CGFloat pageWidth = scrollView.frame.size.width;
int currentPage = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
精彩评论