How do I make the UIScroll view show complete views, not partial views?
(Note) I don’t want it jumping to a complete view. It needs to move naturally or at least not immediate… needs to be smooth.
thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If your views are all of a constant size and you just want left/right or up/down scrolling, set
pagingEnabledon the scroll view toYES. Supposing you wanted your scroll view to be 320×480 but to show the sides of the next and previous pages (so, e.g., each thing inside the view was 280 points wide), you’d size the scroll view to be 280×480 but setmasksToBoundstoNO.If you have a more complicated scheme, install a scroll view delegate and act on
scrollViewDidScroll:, paying attention tocontentOffset. Probably you want to implement logic like:add an observer on
tracking; when it transitions toNOfrom ‘YES’ enable your logic insidescrollViewDidScroll:In there:setContentOffset:animated:) for half a second from nowYou can use a non-repeating
NSTimerfor the scheduling aspect. The logic you’ve essentially implemented is that if the user stops adjusting the view, wait for the natural inertia to end (which you’ll detect by the 0.5 second gap since last movement), then transition smoothly to the nearest aligned position.