User Interface

When creating scenes in storyboards, there are a number of user-interface components that we didn’t need for Pragmatic Podcasts. These include things like text fields and text areas, sliders, progress indicators, and so on. UIKit also offers a collection view that is sort of like a two-dimensional table view—a grid view of cells that your app supplies with a delegate/data source scheme much like UITableView’s. For embedding web content, the WKWebView (in the WebKit framework) provides the same rendering engine as the Safari web browser uses, as a convenient subview that can be added to your view like any other.

If none of the provided views does what we need, it’s possible to create entirely custom views. To do so, we would subclass UIView and then override the drawRect method, using the Core Graphics (introduced below). If the user needs to interact with this view, we can attach gesture recognizers to the view to detect taps, long-presses, swipes, and drags, and have these gestures call our code.

Along with different views, there are also some specialty view controllers beyond the base UIViewController and the UINavigationController we used in our app. The UITabBarController manages a bottom-of-screen tab bar, where each tab is connected to a separate view controller. The UISplitViewController provides the side-by-side master-detail arrangement of view controllers often seen in iPad apps. Both of these are examples of a view controller having child view controllers, where one view controller loads one or more child view controllers and their views when loading from the storyboard. This approach can be set up manually with the container view in the Object Library, and is useful for having two separate controllers on the iPhone, but combining them in one scene for the iPad.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset