150 likes | 302 Views
Views in iOS. Telerik Software Academy. http://academy.telerik.com. Mobile apps for iPhone & iPad. Table of Contents. Views Overview Nib/ Xib files Loading Nib files Creating custom views Creating a custom reusable UITableViewCell Creating a custom UIView Drawing on a view. Views.
E N D
Views in iOS Telerik Software Academy http://academy.telerik.com Mobile appsfor iPhone & iPad
Table of Contents • Views • Overview • Nib/Xib files • Loading Nib files • Creating custom views • Creating a custom reusable UITableViewCell • Creating a custom UIView • Drawing on a view
Views Overview
Views Overview • Views are part of the MVC architecture • They represent the UI of an iOS application • Built from NIB files and Obj-C/Swift classes • NIB/XIB files are files with only UI • NExTSTEP Interface Builder • They have no code, only UI • NIB files can be loaded dynamically • As a resource
Views Hierarchy • Views build an hierarchy of views • The outer/root view is the window • The window contains a storyboard scene • Scenes can contain other views • Views can contain views • Etc…. • When the windows is rendered it sends message to its subviews to render as well • As do they to their subviews and so on…
Creating and Loading NIB Files Live Demo
Creating Custom Views UITableViewCell and UIView
Creating Custom Views • Views can be created by a NIB file and a class that inherits UIView • Or a subclass of UIView • The NIB file and the class are connected the same way as a storyboard scene and a ViewController • Select the View in Interface builder • Open the Utilities toolbox • Go to Identity inspector • Set the class
Linking NIB file and a UIView subclass Live Demo
Creating a Reusable UITableViewCell Live Demo
Creating a Custom View Live Demo
Creating View with Drawings Live Demo
Views in iOS http://academy.telerik.com
Homework • Create a table view cell containing an image and a title • Use it inside a UITableViewController • Create a custom view for representing tabs • Each tab has a title and content • The content is visible only if the tab is selected • Only a single tab can be selected at a time • The content can contain any number of UIViews