Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPad UIViewController best practice for complicated interfaces

I would like to develop an application for iPad, using a layout like that shown in this link:

https://skitch.com/sparkoletto/g13ck/ipad-views-layout

As you can see in the image on one page I would like to insert a UITableView (B), two UIScrollView (one vertical (D) and one horizontal (A)) and a simple UIView (C).

What is the best way to develop such interfaces?

It 'best to use a single ViewController that manages all the views that I need, or create a ViewController for each view, and then combine them all together in another UIViewController?

Thanks

like image 266
Alex Avatar asked Mar 04 '26 02:03

Alex


1 Answers

I disagree with @TomSwift. When these things get complicated, it's very helpful to break them out into their own view controllers. You'll create a view controller of the correct type and then [self.view addSubview:vc.view] at some point.

The problem with making one complicated view controller is that it becomes delegate and datasource for too many things that are internal details of individual subviews. Your delegate methods now need to check which tableview is talking to them, for instance.

Splitting them up also makes it much easier to manage rotation, particularly if you want a different set of views displayed in each orientation. This is good for memory management as well, since the VCs can automatically unload the views you aren't using anymore.

Breaking things up too small is of course also a problem. There is a cost to having separate view controllers, especially if they interact with each other. Having a good feel for when is the right time is the mark of an experienced developer. But for the view you showed, I would almost certainly break it up. Your situation looks very much like UISplitViewController.

like image 82
Rob Napier Avatar answered Mar 05 '26 16:03

Rob Napier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!