2. Topics
Protocols and Delegates
Categories and Selectors
Views and View Controllers
Introduction to View Controllers
Types of View Controllers
Hands on example for
Creating a View Controller
Manipulating Views
Adding Content to Application
Working with Images
Adding Simple Animation
Yahoo! Confidential
2
3. Protocols and Delegates
Protocol
Protocols declare methods that others are expected to implement
Similar to interfaces in other languages
Protocol does not require .m file.
Protocol can have @optional methods
Delegate
It allows one object to delegate part of its behavior to be handled by
another object.
Yahoo! Confidential
3
4. Topics
Protocols and Delegates
Categories and Selectors
Views and View Controllers
Introduction to View Controllers
Types of View Controllers
Hands on example for
Creating a View Controller
Manipulating Views
Adding Content to Application
Working with Images
Adding Simple Animation
Yahoo! Confidential
4
5. Categories and Selectors
Categories:
Lets you add methods to class without having access original code
Access instance variable but can't add new ones
@implementation NSString (NumericComparison)
- (NSComparisonResult) compareNumerically:(NSString *) compareWithString {
// ADD NUMERIC SORTING LOGIC HERE
}
@end
Selectors:
Selector is a way of specifying a method to call
@selector(methodName)
Yahoo! Confidential
5
6. Topics
Protocols and Delegates
Categories and Selectors
Views and View Controllers
Introduction to View Controllers
Types of View Controllers
Hands on example for
Creating a View Controller
Manipulating Views
Adding Content to Application
Working with Images
Adding Simple Animation
Yahoo! Confidential
6
7. Introduction to View Controllers
Link between application’s data and user interface
View controllers are traditional controller objects in the MVC design
pattern
Responsible for fetching/initializing models
Every view controller that Apple provides extends from the
UIViewController class
You Manage Your Content Using Content View Controllers
A content view controller presents content on the screen using a view or a
group of views organized into a view hierarchy.
Container View Controllers Manage Other View Controllers
A container view controller contains content owned by other view controllers.
Yahoo! Confidential
7
8. Introduction to View Controllers
Every view is controlled by only one view controller.
Each view controller interacts with a subset of your app’s data.
For example, the Photo controller needs to know only the photo to be displayed.
Yahoo! Confidential
8
9. Topics
Protocols and Delegates
Categories and Selectors
Views and View Controllers
Introduction to View Controllers
Types of View Controllers
Hands on example for
Creating a View Controller
Manipulating Views
Adding Content to Application
Working with Images
Adding Simple Animation
Yahoo! Confidential
9
10. Types of View Controllers
Most commonly used UI View Controllers
UINavigationController
Navigation Controllers Manage Stacks of Other View Controllers
Yahoo! Confidential
10
12. Types of View Controllers
UITabBarController
Tab Bar Controllers Manage Independent Sets of View Controllers
Yahoo! Confidential
12
13. Types of View Controllers
UIPageViewController
Page View Controllers Manage Paged Display of View Controllers
Apps can use a page view controller to present a paged view of content
The page view controller itself manages the display of one or more
content view controllers, each of which provides a single page of content.
UISplitViewController
Split View Controllers Manage Two Panes of Information
Apps can use a split view controller to manage two panes of
information, where both portions of the interface are themselves managed
by view controllers.
This is interface is similar to a navigation controller, but it takes advantage
of the larger screen size of iPad to present more content at a time.
Yahoo! Confidential
13
14. Types of View Controllers
View Controllers at a glance
Yahoo! Confidential
14
15. Topics
Protocols and Delegates
Categories and Selectors
Views and View Controllers
Introduction to View Controllers
Types of View Controllers
Hands on example for
Creating a View Controller
Manipulating Views
Adding Content to Application
Working with Images
Adding Simple Animation
Yahoo! Confidential
15