UIViewController vs UIView

I'm looking at the UIVeiwController and UIView.  Both have very similar properties and events. (Title is not in the UIView)...otherwise they look identical.


In what case would I use a UIViewController vs a UIView?  The both seem to be able to have other iCL controls within them.  I'm just confused on why I would use one over the other.

Should a UIView always be inside a UIViewController?  Then other iCL controls inside the UIView?

Thanks for any explanation on when to use one over the other.
Regards,
Bryan

Hi, 


You can see both as a panel, each with its own features. UIViewController is more suitable for navigation, rotation and can be used in UITabBarController and UINavigationController, UIView is the base class for all view-based controls (UIButton, UITableview, ...) and can be seen as a simple container, nothing more nothing less. For example UITableView (=UIView) is contained within an UITableViewController (=UIViewController) When adding the UITableView to a UINavigationController, most likely the navigation will not work from main to detail page, rotation will not work. While adding a UITableViewController to an UINavigationController you have special events to initialize it as an root view controller that manages and passes through messages to the UITableViewController.

You can take a look at the following page which explains what an UIViewController is.
http://https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html

Kind Regards, 
Pieter

Pieter Scheldeman2015-04-21 08:53:36

Thanks Pieter!