views:

85

answers:

2

I've been eying the E*TRADE iPad app (visible at http://www.apple.com/ipad/apps-for-ipad/#etrade) and wondering just how they manage to effect a 'carousel of view controllers'. Clearly there's a UIViewController under the covers ... but beyond that I get quite lost.

It's pretty much a UITableView on it's side.

Is there any sample code or projects out there that someone can point me at?

Your clues & other hints are most welcome

M.

A: 

Hi Martin

I seems pretty doable, it is surely a Model-View-Controller all the way through.

They have one viewController that sits at the very top of the hierarchy. To this controller they add a number of other viewControllers views, a ScrollViewController, LittleStockViewController etc. etc. All the viewControllers get their data from a model that is being kept up to date with data, i.e. when you change selection in LittleStockViewer the model changes and all views update. I don't think it differs much in architecture from, say, an image viewer.

Try looking into the composite pattern, thats the way I would go on this one, implementing something like an - (void) update; method and a common interface/protocol for all the children to adhere to.

Best of luck with it:)

RickiG
+1  A: 

It looks like that app is done with two (upper and lower) paging UIScrollViewControllers that hold the different views.

How this works is by creating a scrollView, enabling paging and setting the contentSize to an appropriate value (i.e. width of a view * number of views + (View Padding * number of views))

Here is a classic config for a UIScrollView to enable paging:

scrollView.pagingEnabled = YES;
    scrollView.contentSize = CGSizeMake(x,y);
    scrollView.showsHorizontalScrollIndicator = NO;
    scrollView.showsVerticalScrollIndicator = NO;
    scrollView.scrollsToTop = NO;
    scrollView.delegate = self;

Here is some documentation.

Luke Mcneice