Horizontal scrolling for scrolling coredata objects
I have an iOS app built on CoreData with table view and object detail views.
When in detail view, I would like to scroll horizontally to get a detail view of the next object.
I found PageControl and scrollview. But this will be for over 100 objects in the model.
Does anyone have a good example of this or a resource on how to do this.
thank
Michael
+3
source to share
1 answer
You can create individual views for each master data object and then host those views in a UIScrollView.
You will need to set contentSize:
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * allYourViews.count, scrollView.frame.size.height);
Then collapse all your views and add them to the scrollView:
for(int i = 0; i < allYourViews.count; i++) {
CGRect frame;
frame.origin.x = scrollView.frame.size.width * i;
frame.origin.y = 0;
frame.size = scrollView.frame.size;
if(allYourViews.count > 0) {
UIView* someView = (UIView *)allYourViews[i];
someView.frame = frame;
[scrollView addSubview:someView];
}
}
For more details on how to make scrolling, see this tutorial:
http://www.iosdevnotes.com/2011/03/uiscrollview-paging/
(I don't know how this would be done :-)
0
source to share