I want to know if there is a way to use some view controllers within a view controller which provides the same functionality as Fragment
s in Android?
I want to use custom view controllers so I do not want to use NSTabViewController
, UISplitViewController
etc.
Using the support library, fragments are supported back to all relevant Android versions. Fragments encapsulate views and logic so that it is easier to reuse within activities.
Because an Android fragment is not a view, adding it to an activity looks somewhat different than adding a view (e.g. TextView ). A fragment is added to a ViewGroup inside the activity. The fragment's view is displayed inside this ViewGroup .
A Fragment represents a reusable portion of your app's UI. A fragment defines and manages its own layout, has its own lifecycle, and can handle its own input events. Fragments cannot live on their own--they must be hosted by an activity or another fragment.
A fragment has its own layout and its own behavior with its own lifecycle callbacks. You can add or remove fragments in an activity while the activity is running. You can combine multiple fragments in a single activity to build a multi-pane UI. A fragment can be used in multiple activities.
Container View Controllers
allow to include child view controller inside another view controller. Take a look at the docs by clicking on the "more..." link in the class overview.
Implementing a Container View Controller
A custom UIViewController subclass can also act as a container view controller. A container view controller manages the presentation of content of other view controllers it owns, also known as its child view controllers. A child's view can be presented as-is or in conjunction with views owned by the container view controller....
Using them in storyboards is as simple as dragging the Container View to your view controller.
And Xcode will automatically add a child view controller to it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With