I have a scrollview
with 5 image views of width 88.
I want the scrollview
to scroll to each image view (Not Paging)
and
I want to make an infinite scrollview in iPhone which means the when it scroll to last item it will display a first item next to it..
I have been trying by offset but it stops when move it by offset and also I have used apple street scroller which does not allow me to stop each element in center(just like Picker view)..
Disabling Infinite Scroll However, you can turn it on or off any time by toggling the “Infinite Scroll” option on My Site → Settings → Writing. Additionally, adding a footer widget will also disable the Infinite Scroll option.
Infinite scrolling is a listing-page design approach which loads content continuously as the user scrolls down. It eliminates the need for pagination — breaking content up into multiple pages.
Scroll View is used for displaying content more than the size of the screen. It can contain all of the other UI elements like image views, labels, text views and even another scroll view itself.
Infinite scroll is great for touchscreens and especially for mobile devices. A user can easily swipe down to keep generating new content instead of switching to new tabs, which can feel cumbersome.
First of all, I recommend to use a UITableView so you can maintain the memory usage low. An approach that I had used successfully in a project is the following:
Duplicate the content of your cells, I mean if you have 5 items in this way:
| 1 | 2 | 3 | 4 | 5 |
You should add the same (In a table view with reusable engine that's not a big deal) at the end of the table in order to look like this:
| 1 | 2 | 3 | 4 | 5 | 1 | 2 | 3 | 4 | 5 |
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView == _yourScrollView) {
CGFloat currentOffsetX = scrollView.contentOffset.x;
CGFloat currentOffSetY = scrollView.contentOffset.y;
CGFloat contentHeight = scrollView.contentSize.height;
if (currentOffSetY < (contentHeight / 6.0f)) {
scrollView.contentOffset = CGPointMake(currentOffsetX,(currentOffSetY + (contentHeight/2)));
}
if (currentOffSetY > ((contentHeight * 4)/ 6.0f)) {
scrollView.contentOffset = CGPointMake(currentOffsetX,(currentOffSetY - (contentHeight/2)));
}
}
}
The code above move the scroll position at top if you almost reach the final of the scrolling; Or if you are almost on the top, moves you to the bottom...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With