When to use a UIView vs. a UIViewController on the iPhone?

前端 未结 9 767
谎友^
谎友^ 2020-12-04 16:25

I have always sort of wondered when to use a UIView vs. a UIViewController on the iPhone.

I understand that you shouldn\'t use a UIViewController unless it\'s a full

9条回答
  •  旧时难觅i
    2020-12-04 16:54

    From Apple's View Controller Programming Guide for iOS:

    "The most important role of a view controller is to manage a hierarchy of views. Every view controller has a single root view that encloses all of the view controller’s content. To that root view, you add the views you need to display your content."

    Also:

    "There are two types of view controllers:

    • Content view controllers manage a discrete piece of your app’s content and are the main type of view controller that you create.
    • Container view controllers collect information from other view controllers (known as child view controllers) and present it in a way that facilitates navigation or presents the content of those view controllers differently.

    Most apps are a mixture of both types of view controllers."

提交回复
热议问题