SlideShare ist ein Scribd-Unternehmen logo
1 von 43
Downloaden Sie, um offline zu lesen
In This Deck
This deck is shared with you under a Creative Commons license.
Views
UIView
UIVisualEffectView
UIScrollView
View Controllers
UIViewController
UITableViewController (+ UITableView + UITableViewCell)
UICollectionViewController (+ UICollectionView +
UICollectionViewCell)
Coordinating View Controllers
UINavigationController (+ UINavigationBar)
UITabBarController (+ UITabBar + UITabBarItem)
UISplitViewController
UIStoryboardSegue
Content Views
UIImageView
MKMapView
UIWebView
Indicator Views
UIActivityIndicatorView
UIProgressView
UIPageControl
Other Topics
UIGestureRecognizer
Core Graphics & Core Animation
Controls
UIButton
UISwitch
UISegmentedControl
UIStepper
UISlider
UIPickerView / UIDatePicker
UIToolbar (+ UIBarButtonItem)
Text Entry
UITextField
UITextView
Modal Dialogues
UIAlertController
Views
UIView • UIVisualEffectView • UIScrollView
Views
UIView
UIView : UIResponder : NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/
A view defines a rectangular area on the screen and
the interfaces for managing the content in that area.
They are the main way your application interacts
with the user:
● Responsibilities include drawing, animation, layout and
subview management, and event handling
● Views embedded inside another view are subviews.
Views that contain embedded subviews are
superviews to those subviews.
● A view’s size and position are defined by its frame,
bounds, center, and origin
● The frame completely surrounds the bounds
view.frame =
CGRectMake(50.0,
100.0, 200.0, 100.0);
view.origin =
CGPointMake(50.0,
100.0);
view.bounds =
CGRectMake(0.0, 0.0,
200.0, 100.0);
card.frame
card.bounds
Views
UIVisualEffectView
UIVisualEffectView : UIView : UIResponder : NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIVisualEffectView/
A visual effect view is a view that allows for dynamic
blurring of the content it obstructs in addition to
adding vibrancy so that content in the visual effect
view appears more vivid:
● Used widely throughout iOS 7
● Available for developer use in iOS 8.0 and later
● Maintains visual hierarchy of user interface elements
● Used with UIBlurEffect and UIVibrancyEffect
classes to create effect
UIVisualEffectView
Views
UIScrollView
UIScrollView : UIView : UIResponder : NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScrollView_Class/
A scroll view is an interface that allows for the display
of content potentially larger than the view itself:
● Users scroll by making swipe gestures to move content
● Users zoom by pinching content in and out
● frame operates like UIView, but bounds determine size
and offset of scroll view’s content
● Patented rubber-banding effect indicates that the user
has reached the end of content
● Scroll views can scroll continuously or be paginated in
multiples of the scroll view’s frame.size
There are two UIScrollView
and one UITableView on the
iOS lock screen when 1
notification is present!
UIScrollView
UITableView
View Controllers
UIViewController • UITableViewController (+ UITableView + UITableViewCell)
UIViewController : UIResponder : NSObject
View Controllers
UIViewController
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/
A view controller manages a set of views that make
up a portion of your app’s user interface:
● Resizes and lays out its views
● Adjusts the contents of the views
● Acts on behalf of the views when the user interacts
with them
● Tightly bound to the views it manages and takes part in
the responder chain used to handle events
● Often used with other view controllers, each of which
owns a portion of your app’s user interface
Status Bar
(not part of
view
controller)
Is Initial
View
Controller
self.view
Outlet to
view
controller
class
UITableViewController : UIViewController :
UIResponder : NSObject
View Controllers
UITableViewController
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewController_Class/
A table view controller manages a table view that
displays data using reusable table view cells:
● UITableView is a vertically-scrolling scroll view with two
delegates: datasource <UITableViewDataSource> and
delegate <UITableViewDelegate>
● Only a necessary number of table view cell instances
are kept in memory—as soon as a cell scrolls out of
view, it is no longer retained or else it is reused
● Table views can have multiple sections, each with their
own header and footer
● Cells can be added, selected, rearranged, and deleted
with the proper method implementations
Section
Headers
UITableViewCel
l
Separator
UITableView
UICollectionViewController : UIViewController :
UIResponder : NSObject
View Controllers
UITableViewController
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewController_Class/
A collection view controller manages a view that
displays data using reusable stackable cells:
● UICollectionView has two delegates: datasource
<UICollectionViewDataSource> and delegate
<UICollectionViewDelegate>
● Only a necessary number of collection view cell
instances are kept in memory—as soon as a cell scrolls
out of view, it is no longer retained or else it is reused
● Collection views can have multiple sections, each with
their own header and footer
● Cells can be added, selected, rearranged, and deleted
with the proper method implementations
UICollectionView
UICollectionViewCell
Coordinating View Controllers
UINavigationController (+ UINavigationBar) • UITabBarController (+ UITabBar + UITabBarItem)
UISplitViewController • UIStoryboardSegue
UINavigationController : UIViewController :
UIResponder : NSObject
Coordinating View Controllers
UINavigationController
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UINavigationController_Class/
A navigation controller manages the navigation of
hierarchical content (i.s., other view controllers):
● Presents navigation bar with title, bar button items,
and back button to previous view controller
● Child view controllers are held in self.
viewControllers
● Navigation controller pushes child view controllers to
present them and pops them when navigating back to
parent view controller
● Can also navigate back to parent view controller by
swiping from left edge of view
Navigation Bar
Root View
Controller
Segue
UITabBarController : UIViewController : UIResponder
: NSObject
Coordinating View Controllers
UITabBarController
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITabBarController_Class/
A tab bar controller displays tabs at the bottom of
the window for selecting between the different
modes and for displaying the views for that mode:
● Generally a top-level view controller – sits above
navigation controllers
● Up to five items can be shown in the tab bar – if more
than five items, the fifth item becomes “More”
● Each tab bar item connects to a child view controller
● Each tab bar item is of class UITabBarItem
Tab Bar
UISplitViewController : UIViewController :
UIResponder : NSObject
Coordinating View Controllers
UISplitViewController
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISplitViewController_Class/
A split view controller controller displays a master-
detail interface where changes in the primary view
controller drive changes in the secondary view
controller:
● Prior to iOS 8, split view controller was only available
on iPad
● Is typically the root view controller of your app’s
window, even above tab bar controllers
● When horizontal width is compact (e.g., iPhone
portrait), generally acts like a navigation controller
Master View
Controller
Detail View
Controller
UIStoryboardSegue : NSObject
Coordinating View Controllers
UIStoryboardSegue
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIStoryboardSegue_Class/
A segue is responsible for performing the visual
transition between two view controllers:
● Also contains information about the view controllers
involved in the segue
● Five types: Show, Modal, Popover, Replace, & Custom
● Segues are usually defined in Interface Builder (i.e.,
Storyboard), but you can also initiate segues
programmatically using -[UIViewController
performSegueWithIdentifier:sender:]
● Performing segue also triggers -[UIViewController
prepareForSegue:sender:] before performing segue
Segue
Coordinating View Controllers
UIStoryboardSegue
Modal
Cover Vertical • Flip Horizontal
Cross Dissolve • Page Curl
Popover
Used on iPad
Show
Used within navigation
controllers
Custom
Requires custom
implementation in code
Controls
UIButton • UISwitch • UISegmentedControl • UIStepper • UISlider
UIPickerView / UIDatePicker • UIToolbar (+ UIBarButtonItem)
Controls
UIButton
UIButton : UIControl : UIView : UIResponder :
NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIButton_Class/
A button intercepts touch events and sends an
action message to a target object when tapped, e.g.:
● UIControlEventTouchUpInside: A touch-up event in the control
where the finger is inside the bounds of the control.
● UIControlEventTouchDown: A touch-down event in the control
● UIControlEventTouchDownRepeat: A repeated touch-down event
in the control; for this event the value of the UITouch tapCount
method is greater than one.
● UIControlEventAllTouchEvents: All touch events.
● UIControlEventAllEvents: All events, including system events.
continued...
UIButton with colored
titleLabel
UIButton with border
UIButton without
border
Controls
UIButton
UIButton : UIControl : UIView : UIResponder :
NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIControl_Class/
● UIControlEventTouchDragEnter: An event where a finger is
dragged into the bounds of the control.
● UIControlEventTouchDragInside: An event where a finger is
dragged inside the bounds of the control.
● UIControlEventTouchDragOutside: An event where a finger is
dragged just outside the bounds of the control.
● UIControlEventTouchDragExit: An event where a finger is
dragged from within a control to outside its bounds.
● UIControlEventTouchCancel: A system event canceling the
current touches for the control.
A full list is available within the documentation for
UIControl.
UIButton with colored
titleLabel
UIButton with border
UIButton without
border
Controls
UISwitch
UISwitch : UIControl : UIView : UIResponder :
NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISwitch_Class/
A switch is a control designed for setting bool values
to YES or NO:
● Generates UIControlEventValueChanged notification
when switched on or off
● Can set tintColor, thumbTintColor, and onTintColor
for added customization
UISwitch
Controls
UISegmentedControl
UISegmentedControl : UIControl : UIView :
UIResponder : NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISegmentedControl_Class/
A segmented control is a horizontal control that
allows the user to select from one of multiple
discrete related states:
● Each segmented control can display an NSString or a
UIImage
● Changing values triggers
UIControlEventValueChanged event
● Used within a view controller (i.e., should not trigger a
segue or change in view controller)
UISegmentedControl
Selected segment
Controls
UIStepper
UIStepper : UIControl : UIView : UIResponder :
NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIStepper_Class/
A stepper is used for incrementing and
decrementing a value at a predetermined step size:
● Has properties value, minimumValue, maximumValue,
and stepValue
● Can set autorepeat, i.e., whether holding stepper
repeatedly increments or decrements value
● Can set continuous, i.e., whether value change is sent
immediately or when user interaction ends
● Can set wraps, i.e., whether incrementing beyond
maximum or decrementing below minimum resets
value to minimum or maximum
Food for Thought: Does UIStepper violate MVC architecture?
Controls
UISlider
UISlider : UIControl : UIView : UIResponder :
NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISlider_Class/
A slider is a visual control used to select a single
value from a continuous range of values:
● Always displayed horizontally in iOS
● The thumb rides along the track
● Can set custom icons for minimumValueImage and
maximumValueImage
● Like UISlider, can set value, minimumValue,
maximumValue, and continuous
● Unlike UISlider, no stepValue or wraps
Controls
UIPickerView
UIPickerView : UIView : UIResponder : NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIPickerView_Class/
A picker view uses a slot machine metaphor for
setting one or more sets of values so that the
desired values align with a selection indicator:
● Picker view consists of components and rows
● Each component can have a different number of rows
● Items for rows can be strings or view objects (e.g.,
UILabel, UIImage)
● Has datasource <UIPickerViewDataSource> and
delegate <UIPickerViewDelegate>
UIPickerView
Controls
UIDatePicker
UIDatePicker : UIControl : UIView : UIResponder :
NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDatePicker_Class/
A date picker provides multiple rotating wheels to
select values for dates and times:
● Does not inherit from UIPickerView; instead, manages
a custom UIPickerView as a subview
● Sends event UIControlEventValueChanged each time
user finishes rotating a wheel
● Can set calendar, locale, and timeZone for correct
internationalization per device settings
● Date value stored in NSDate property date
● Can set datePickerMode to UIDatePickerMode value
UIDatePicker
Controls
UIToolbar
UIToolbar : UIView : UIResponder : NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIToolbar_Class/
A toolbar displays one or more buttons, called
toolbar items (UIBarButtonItem):
● Buttons should be actions, not toggles
● Toolbars can be customized by setting barStyle,
barTintColor, tintColor, and translucent and/or
implementing background and shadow images
● Has delegate <UIToolbarDelegate> that follows
<UIBarPositioningDelegate> protocol
UIToolbar
UIBarButtonItem
Text Entry
UITextField • UITextView
Text Entry
UITextField
UITextField : UIControl : UIView : UIResponder :
NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextField_Class/
A text field displays editable text and is used to
gather small amounts of text from the user:
● Has property delegate <UITextFieldDelegate> to
handle user events
● Can set text by setting text or attributedText
properties
● Can set placeholder, font, textColor, textAlignment,
borderStyle, background, etc.
● Tapping automatically brings up keyboard
● To dismiss keyboard, call resignFirstResponder
Text Entry
UITextView
UITextView : UIScrollView : UIView : UIResponder :
NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextView_Class/
A text view is a scrollable, multiline text region that
also supports text editing, typically used to display
multiple lines of text:
● Has property delegate <UITextViewDelegate> to
handle user events
● Can set text by setting text or attributedText
properties
● Can set font, textColor, textAlignment, borderStyle,
etc.
● Tapping automatically brings up keyboard
● To dismiss keyboard, call resignFirstResponder
UITextView
Modal Dialogues
UIAlertController
Modal Dialogues
UIAlertController
UIAlertController : UIViewController : UIResponder :
NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAlertController_Class/
An alert controller displays an alert message to the
user:
● Replaces both UIAlertView and UIActionSheet in iOS
8 and above
● Does not support subclassing!
● Alert itself has title, message, and preferredStyle
(either UIAlertControllerStyleAlert or
UIAlertControllerStyleActionSheet)
● Actions added using UIAlertAction class
● Shown using -[presentViewController:animated:
completion:]
Content Views
UIImageView • MKMapView • UIWebView
Content Views
UIImageView
UIImageView : UIView : UIResponder : NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImageView_Class/
An image view is a view-based container for
displaying either a single image or for animating a
series of images:
● Can set single UIImage to image or array of UIImage
objects to animationImages
● If both image and animationImages are set,
animationImages takes precedence
● Be sure to include image.png, image@2x.png, and
image@3x.png files in Xcode to support non-Retina,
Retina, and Retina HD screen resolutions
UIImageView
Content Views
MKMapView
MKMapView : UIView : UIResponder : NSObject
https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapView_Class/
A map view is an embeddable map interface similar
to the one provided by the Maps application:
● Used as-is using whatever Maps provider is defined by
the system (i.e., Google Maps for iOS 5.1 and earlier;
Apple Maps for iOS 6 and later)
● Has delegate <MKMapViewDelegate>
● Can set region, scrollEnabled, zoomEnabled,
pitchEnabled
● Can set MKAnnotation with reusable
MKAnnotationView to add pins to map
● Can use MKOverlay to add overlay to map
Full screen
MKMapView
UIView provided by
MKMapViewDelegate via -
[mapView:viewForAnnotation:]
MKAnnotationView
MKOverlay for traffic
Content Views
UIWebView
UIWebView : UIView : UIResponder : NSObject
https://developer.apple.com/library/ios/documentation/MapKit/Reference/UIWebView_Class/
A web view is used to embed web content:
● Has delegate <UIWebViewDelegate> to perform
methods as web view is about to, starts to, finishes,
and fails to load
● Can perform standard methods for displaying and
managing web sites (e.g., stopLoading, reload,
goForward, goBack)
● Send NSURLRequest via loadRequest: to open web
page
● Visually indistinguishable from UIView
● Currently accessory views need to be made manually
(e.g., toolbar, buttons, URL bar)
UIWebView
Indicator Views
UIActivityIndicatorView • UIProgressView • UIPageControl
Indicator Views
UIActivityIndicatorView
UIActivityIndicatorView : UIView : UIResponder :
NSObject
https://developer.apple.com/library/ios/documentation/MapKit/Reference/UIActivityIndicatorView_Class/
An activity indicator shows that a task is in progress
and appears as a “gear” that is either spinning or
stopped:
● Only customization options are color (iOS 5.0 and
later) and activityIndicatorViewStyle (either
UIActivityIndicatorViewStyleGray,
UIActivityIndicatorViewStyleWhite, or
UIActivityIndicatorViewStyleWhiteLarge)
● Start and stop animating by calling startAnimating
and stopAnimating
● Best used when the length of time is uncertain or
indeterminate and cannot be predicted
UIActivityIndicatorView
Indicator Views
UIProgressView
UIProgressView : UIView : UIResponder : NSObject
https://developer.apple.com/library/ios/documentation/MapKit/Reference/UIProgressView_Class/
A progress view visualizes the completion of a task
over time:
● Used when the length of time or task length is known
ahead of time
● Set progress using method setProgress:animated: as
a float between 0.0 and 1.0
● Customizations include trackTintColor, trackImage,
progressTintColor, progressImage, and
progressViewStyle
UIProgressView
(yes, it’s there, I swear!)
Indicator Views
UIPageControl
UIPageControl : UIControl : UIView : UIResponder :
NSObject
https://developer.apple.com/library/ios/documentation/MapKit/Reference/UIPageControl_Class/
A page control displays a horizontal series of dots,
each of which corresponds to a single page or item:
● While UIPageControl is itself a control that you can tap
on to change pages, most users will change pages
using other methods (e.g., swiping on content)
● Can set hidesForSinglePage to YES if you want
UIPageControl not to be visible if only 1 page
● Can set pageIndicatorTintColor and
currentPageIndicatorTintColor
● Generally positioned below paginated content
● Custom dots require custom UIPageControl subclass
Paginated content
UIPageControl
Other Topics
UIGestureRecognizer • Core Graphics & Core Animation
Other Topics
UIGestureRecognizer
A gesture recognizer is used to recognize a touch
event:
● Decouples recognition logic from action logic
● Multiple gesture recognizers can be applied to the
same view; however, be aware of how doing so will
affect the user experience
○ E.g., if a view has both a tap gesture recognizer
and a long press gesture recognizer, how do you
distinguish the two? Should the tap gesture be
laggy? Or should the long press gesture be
delayed?
● Be careful of incomplete gestures
UIGestureRecognizer : NSObject
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIGestureRecognizer_Class/
Fast Company © 2012
Other Topics
Core Graphics & Core Animation
https://developer.apple.
com/library/mac/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction/Introducti
on.html
The Core Graphics framework allows you to create
your own custom graphics programmatically.
● E.g., Draw polygons, gradients, and lines
● Apply transforms to UIView
● Using Core Graphics instead of image files can make
your app faster and leaner
The Core Animation framework allows you to create
your own custom animations programmatically:
● An animation is defined by its start state, its end state,
how long it takes to transition, and how it transitions
Example
Clock
Take a look at your favorite app!
How was it built?
How many user interface elements can you identify?

Weitere ähnliche Inhalte

Was ist angesagt?

Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code first
Confiz
 

Was ist angesagt? (20)

INTRODUCTION TO FLUTTER BASICS.pptx
INTRODUCTION TO FLUTTER BASICS.pptxINTRODUCTION TO FLUTTER BASICS.pptx
INTRODUCTION TO FLUTTER BASICS.pptx
 
Swift in SwiftUI
Swift in SwiftUISwift in SwiftUI
Swift in SwiftUI
 
Flutter presentation.pptx
Flutter presentation.pptxFlutter presentation.pptx
Flutter presentation.pptx
 
Asp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework CoreAsp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework Core
 
Asp.Net Core MVC with Entity Framework
Asp.Net Core MVC with Entity FrameworkAsp.Net Core MVC with Entity Framework
Asp.Net Core MVC with Entity Framework
 
Ios development
Ios developmentIos development
Ios development
 
React Native na globo.com
React Native na globo.comReact Native na globo.com
React Native na globo.com
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
 
Message Queuing (MSMQ)
Message Queuing (MSMQ)Message Queuing (MSMQ)
Message Queuing (MSMQ)
 
Android App Development - 05 Action bar
Android App Development - 05 Action barAndroid App Development - 05 Action bar
Android App Development - 05 Action bar
 
Angular components
Angular componentsAngular components
Angular components
 
.Net Core
.Net Core.Net Core
.Net Core
 
ASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP Fundamentals
 
Android Development - ConstraintLayout
Android Development - ConstraintLayoutAndroid Development - ConstraintLayout
Android Development - ConstraintLayout
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
 
Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code first
 
Deep dive into swift UI
Deep dive into swift UIDeep dive into swift UI
Deep dive into swift UI
 
Flutter state management from zero to hero
Flutter state management from zero to heroFlutter state management from zero to hero
Flutter state management from zero to hero
 

Ähnlich wie Intro to UIKit • Made by Many

iPhone Development: Multiple Views
iPhone Development: Multiple ViewsiPhone Development: Multiple Views
iPhone Development: Multiple Views
Jussi Pohjolainen
 
Session 13 - Working with navigation and tab bar
Session 13 - Working with navigation and tab barSession 13 - Working with navigation and tab bar
Session 13 - Working with navigation and tab bar
Vu Tran Lam
 
아이폰강의(5) pdf
아이폰강의(5) pdf아이폰강의(5) pdf
아이폰강의(5) pdf
sunwooindia
 
Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)
Michael Shrove
 
Session 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 applicationSession 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 application
Vu Tran Lam
 

Ähnlich wie Intro to UIKit • Made by Many (20)

iPhone Development: Multiple Views
iPhone Development: Multiple ViewsiPhone Development: Multiple Views
iPhone Development: Multiple Views
 
Objective c design pattens-architetcure
Objective c design pattens-architetcureObjective c design pattens-architetcure
Objective c design pattens-architetcure
 
iOS: View Controllers
iOS: View ControllersiOS: View Controllers
iOS: View Controllers
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)
 
Swift
SwiftSwift
Swift
 
Session 13 - Working with navigation and tab bar
Session 13 - Working with navigation and tab barSession 13 - Working with navigation and tab bar
Session 13 - Working with navigation and tab bar
 
Swf2 ui
Swf2 uiSwf2 ui
Swf2 ui
 
아이폰강의(5) pdf
아이폰강의(5) pdf아이폰강의(5) pdf
아이폰강의(5) pdf
 
Creating Container View Controllers
Creating Container View ControllersCreating Container View Controllers
Creating Container View Controllers
 
Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
 
Session 15 - Working with Image, Scroll, Collection, Picker, and Web View
Session 15  - Working with Image, Scroll, Collection, Picker, and Web ViewSession 15  - Working with Image, Scroll, Collection, Picker, and Web View
Session 15 - Working with Image, Scroll, Collection, Picker, and Web View
 
I os 11
I os 11I os 11
I os 11
 
SwiftでUIKitDynamics
SwiftでUIKitDynamicsSwiftでUIKitDynamics
SwiftでUIKitDynamics
 
IOS APPs Revision
IOS APPs RevisionIOS APPs Revision
IOS APPs Revision
 
занятие6
занятие6занятие6
занятие6
 
Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)
 
Session 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 applicationSession 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 application
 
December 2014 University iOS Meetup Talk
December 2014 University iOS Meetup TalkDecember 2014 University iOS Meetup Talk
December 2014 University iOS Meetup Talk
 
iOS training (intermediate)
iOS training (intermediate)iOS training (intermediate)
iOS training (intermediate)
 
Conductor vs Fragments
Conductor vs FragmentsConductor vs Fragments
Conductor vs Fragments
 

Kürzlich hochgeladen

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 

Kürzlich hochgeladen (20)

WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 

Intro to UIKit • Made by Many

  • 1.
  • 2. In This Deck This deck is shared with you under a Creative Commons license. Views UIView UIVisualEffectView UIScrollView View Controllers UIViewController UITableViewController (+ UITableView + UITableViewCell) UICollectionViewController (+ UICollectionView + UICollectionViewCell) Coordinating View Controllers UINavigationController (+ UINavigationBar) UITabBarController (+ UITabBar + UITabBarItem) UISplitViewController UIStoryboardSegue Content Views UIImageView MKMapView UIWebView Indicator Views UIActivityIndicatorView UIProgressView UIPageControl Other Topics UIGestureRecognizer Core Graphics & Core Animation Controls UIButton UISwitch UISegmentedControl UIStepper UISlider UIPickerView / UIDatePicker UIToolbar (+ UIBarButtonItem) Text Entry UITextField UITextView Modal Dialogues UIAlertController
  • 4. Views UIView UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/ A view defines a rectangular area on the screen and the interfaces for managing the content in that area. They are the main way your application interacts with the user: ● Responsibilities include drawing, animation, layout and subview management, and event handling ● Views embedded inside another view are subviews. Views that contain embedded subviews are superviews to those subviews. ● A view’s size and position are defined by its frame, bounds, center, and origin ● The frame completely surrounds the bounds view.frame = CGRectMake(50.0, 100.0, 200.0, 100.0); view.origin = CGPointMake(50.0, 100.0); view.bounds = CGRectMake(0.0, 0.0, 200.0, 100.0); card.frame card.bounds
  • 5. Views UIVisualEffectView UIVisualEffectView : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIVisualEffectView/ A visual effect view is a view that allows for dynamic blurring of the content it obstructs in addition to adding vibrancy so that content in the visual effect view appears more vivid: ● Used widely throughout iOS 7 ● Available for developer use in iOS 8.0 and later ● Maintains visual hierarchy of user interface elements ● Used with UIBlurEffect and UIVibrancyEffect classes to create effect UIVisualEffectView
  • 6. Views UIScrollView UIScrollView : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScrollView_Class/ A scroll view is an interface that allows for the display of content potentially larger than the view itself: ● Users scroll by making swipe gestures to move content ● Users zoom by pinching content in and out ● frame operates like UIView, but bounds determine size and offset of scroll view’s content ● Patented rubber-banding effect indicates that the user has reached the end of content ● Scroll views can scroll continuously or be paginated in multiples of the scroll view’s frame.size There are two UIScrollView and one UITableView on the iOS lock screen when 1 notification is present! UIScrollView UITableView
  • 7. View Controllers UIViewController • UITableViewController (+ UITableView + UITableViewCell)
  • 8. UIViewController : UIResponder : NSObject View Controllers UIViewController https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/ A view controller manages a set of views that make up a portion of your app’s user interface: ● Resizes and lays out its views ● Adjusts the contents of the views ● Acts on behalf of the views when the user interacts with them ● Tightly bound to the views it manages and takes part in the responder chain used to handle events ● Often used with other view controllers, each of which owns a portion of your app’s user interface Status Bar (not part of view controller) Is Initial View Controller self.view Outlet to view controller class
  • 9. UITableViewController : UIViewController : UIResponder : NSObject View Controllers UITableViewController https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewController_Class/ A table view controller manages a table view that displays data using reusable table view cells: ● UITableView is a vertically-scrolling scroll view with two delegates: datasource <UITableViewDataSource> and delegate <UITableViewDelegate> ● Only a necessary number of table view cell instances are kept in memory—as soon as a cell scrolls out of view, it is no longer retained or else it is reused ● Table views can have multiple sections, each with their own header and footer ● Cells can be added, selected, rearranged, and deleted with the proper method implementations Section Headers UITableViewCel l Separator UITableView
  • 10. UICollectionViewController : UIViewController : UIResponder : NSObject View Controllers UITableViewController https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewController_Class/ A collection view controller manages a view that displays data using reusable stackable cells: ● UICollectionView has two delegates: datasource <UICollectionViewDataSource> and delegate <UICollectionViewDelegate> ● Only a necessary number of collection view cell instances are kept in memory—as soon as a cell scrolls out of view, it is no longer retained or else it is reused ● Collection views can have multiple sections, each with their own header and footer ● Cells can be added, selected, rearranged, and deleted with the proper method implementations UICollectionView UICollectionViewCell
  • 11. Coordinating View Controllers UINavigationController (+ UINavigationBar) • UITabBarController (+ UITabBar + UITabBarItem) UISplitViewController • UIStoryboardSegue
  • 12. UINavigationController : UIViewController : UIResponder : NSObject Coordinating View Controllers UINavigationController https://developer.apple.com/library/ios/documentation/UIKit/Reference/UINavigationController_Class/ A navigation controller manages the navigation of hierarchical content (i.s., other view controllers): ● Presents navigation bar with title, bar button items, and back button to previous view controller ● Child view controllers are held in self. viewControllers ● Navigation controller pushes child view controllers to present them and pops them when navigating back to parent view controller ● Can also navigate back to parent view controller by swiping from left edge of view Navigation Bar Root View Controller Segue
  • 13. UITabBarController : UIViewController : UIResponder : NSObject Coordinating View Controllers UITabBarController https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITabBarController_Class/ A tab bar controller displays tabs at the bottom of the window for selecting between the different modes and for displaying the views for that mode: ● Generally a top-level view controller – sits above navigation controllers ● Up to five items can be shown in the tab bar – if more than five items, the fifth item becomes “More” ● Each tab bar item connects to a child view controller ● Each tab bar item is of class UITabBarItem Tab Bar
  • 14. UISplitViewController : UIViewController : UIResponder : NSObject Coordinating View Controllers UISplitViewController https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISplitViewController_Class/ A split view controller controller displays a master- detail interface where changes in the primary view controller drive changes in the secondary view controller: ● Prior to iOS 8, split view controller was only available on iPad ● Is typically the root view controller of your app’s window, even above tab bar controllers ● When horizontal width is compact (e.g., iPhone portrait), generally acts like a navigation controller Master View Controller Detail View Controller
  • 15. UIStoryboardSegue : NSObject Coordinating View Controllers UIStoryboardSegue https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIStoryboardSegue_Class/ A segue is responsible for performing the visual transition between two view controllers: ● Also contains information about the view controllers involved in the segue ● Five types: Show, Modal, Popover, Replace, & Custom ● Segues are usually defined in Interface Builder (i.e., Storyboard), but you can also initiate segues programmatically using -[UIViewController performSegueWithIdentifier:sender:] ● Performing segue also triggers -[UIViewController prepareForSegue:sender:] before performing segue Segue
  • 16. Coordinating View Controllers UIStoryboardSegue Modal Cover Vertical • Flip Horizontal Cross Dissolve • Page Curl Popover Used on iPad Show Used within navigation controllers Custom Requires custom implementation in code
  • 17. Controls UIButton • UISwitch • UISegmentedControl • UIStepper • UISlider UIPickerView / UIDatePicker • UIToolbar (+ UIBarButtonItem)
  • 18. Controls UIButton UIButton : UIControl : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIButton_Class/ A button intercepts touch events and sends an action message to a target object when tapped, e.g.: ● UIControlEventTouchUpInside: A touch-up event in the control where the finger is inside the bounds of the control. ● UIControlEventTouchDown: A touch-down event in the control ● UIControlEventTouchDownRepeat: A repeated touch-down event in the control; for this event the value of the UITouch tapCount method is greater than one. ● UIControlEventAllTouchEvents: All touch events. ● UIControlEventAllEvents: All events, including system events. continued... UIButton with colored titleLabel UIButton with border UIButton without border
  • 19. Controls UIButton UIButton : UIControl : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIControl_Class/ ● UIControlEventTouchDragEnter: An event where a finger is dragged into the bounds of the control. ● UIControlEventTouchDragInside: An event where a finger is dragged inside the bounds of the control. ● UIControlEventTouchDragOutside: An event where a finger is dragged just outside the bounds of the control. ● UIControlEventTouchDragExit: An event where a finger is dragged from within a control to outside its bounds. ● UIControlEventTouchCancel: A system event canceling the current touches for the control. A full list is available within the documentation for UIControl. UIButton with colored titleLabel UIButton with border UIButton without border
  • 20. Controls UISwitch UISwitch : UIControl : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISwitch_Class/ A switch is a control designed for setting bool values to YES or NO: ● Generates UIControlEventValueChanged notification when switched on or off ● Can set tintColor, thumbTintColor, and onTintColor for added customization UISwitch
  • 21. Controls UISegmentedControl UISegmentedControl : UIControl : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISegmentedControl_Class/ A segmented control is a horizontal control that allows the user to select from one of multiple discrete related states: ● Each segmented control can display an NSString or a UIImage ● Changing values triggers UIControlEventValueChanged event ● Used within a view controller (i.e., should not trigger a segue or change in view controller) UISegmentedControl Selected segment
  • 22. Controls UIStepper UIStepper : UIControl : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIStepper_Class/ A stepper is used for incrementing and decrementing a value at a predetermined step size: ● Has properties value, minimumValue, maximumValue, and stepValue ● Can set autorepeat, i.e., whether holding stepper repeatedly increments or decrements value ● Can set continuous, i.e., whether value change is sent immediately or when user interaction ends ● Can set wraps, i.e., whether incrementing beyond maximum or decrementing below minimum resets value to minimum or maximum Food for Thought: Does UIStepper violate MVC architecture?
  • 23. Controls UISlider UISlider : UIControl : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISlider_Class/ A slider is a visual control used to select a single value from a continuous range of values: ● Always displayed horizontally in iOS ● The thumb rides along the track ● Can set custom icons for minimumValueImage and maximumValueImage ● Like UISlider, can set value, minimumValue, maximumValue, and continuous ● Unlike UISlider, no stepValue or wraps
  • 24. Controls UIPickerView UIPickerView : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIPickerView_Class/ A picker view uses a slot machine metaphor for setting one or more sets of values so that the desired values align with a selection indicator: ● Picker view consists of components and rows ● Each component can have a different number of rows ● Items for rows can be strings or view objects (e.g., UILabel, UIImage) ● Has datasource <UIPickerViewDataSource> and delegate <UIPickerViewDelegate> UIPickerView
  • 25. Controls UIDatePicker UIDatePicker : UIControl : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDatePicker_Class/ A date picker provides multiple rotating wheels to select values for dates and times: ● Does not inherit from UIPickerView; instead, manages a custom UIPickerView as a subview ● Sends event UIControlEventValueChanged each time user finishes rotating a wheel ● Can set calendar, locale, and timeZone for correct internationalization per device settings ● Date value stored in NSDate property date ● Can set datePickerMode to UIDatePickerMode value UIDatePicker
  • 26. Controls UIToolbar UIToolbar : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIToolbar_Class/ A toolbar displays one or more buttons, called toolbar items (UIBarButtonItem): ● Buttons should be actions, not toggles ● Toolbars can be customized by setting barStyle, barTintColor, tintColor, and translucent and/or implementing background and shadow images ● Has delegate <UIToolbarDelegate> that follows <UIBarPositioningDelegate> protocol UIToolbar UIBarButtonItem
  • 28. Text Entry UITextField UITextField : UIControl : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextField_Class/ A text field displays editable text and is used to gather small amounts of text from the user: ● Has property delegate <UITextFieldDelegate> to handle user events ● Can set text by setting text or attributedText properties ● Can set placeholder, font, textColor, textAlignment, borderStyle, background, etc. ● Tapping automatically brings up keyboard ● To dismiss keyboard, call resignFirstResponder
  • 29. Text Entry UITextView UITextView : UIScrollView : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextView_Class/ A text view is a scrollable, multiline text region that also supports text editing, typically used to display multiple lines of text: ● Has property delegate <UITextViewDelegate> to handle user events ● Can set text by setting text or attributedText properties ● Can set font, textColor, textAlignment, borderStyle, etc. ● Tapping automatically brings up keyboard ● To dismiss keyboard, call resignFirstResponder UITextView
  • 31. Modal Dialogues UIAlertController UIAlertController : UIViewController : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAlertController_Class/ An alert controller displays an alert message to the user: ● Replaces both UIAlertView and UIActionSheet in iOS 8 and above ● Does not support subclassing! ● Alert itself has title, message, and preferredStyle (either UIAlertControllerStyleAlert or UIAlertControllerStyleActionSheet) ● Actions added using UIAlertAction class ● Shown using -[presentViewController:animated: completion:]
  • 32. Content Views UIImageView • MKMapView • UIWebView
  • 33. Content Views UIImageView UIImageView : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImageView_Class/ An image view is a view-based container for displaying either a single image or for animating a series of images: ● Can set single UIImage to image or array of UIImage objects to animationImages ● If both image and animationImages are set, animationImages takes precedence ● Be sure to include image.png, image@2x.png, and image@3x.png files in Xcode to support non-Retina, Retina, and Retina HD screen resolutions UIImageView
  • 34. Content Views MKMapView MKMapView : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapView_Class/ A map view is an embeddable map interface similar to the one provided by the Maps application: ● Used as-is using whatever Maps provider is defined by the system (i.e., Google Maps for iOS 5.1 and earlier; Apple Maps for iOS 6 and later) ● Has delegate <MKMapViewDelegate> ● Can set region, scrollEnabled, zoomEnabled, pitchEnabled ● Can set MKAnnotation with reusable MKAnnotationView to add pins to map ● Can use MKOverlay to add overlay to map Full screen MKMapView UIView provided by MKMapViewDelegate via - [mapView:viewForAnnotation:] MKAnnotationView MKOverlay for traffic
  • 35. Content Views UIWebView UIWebView : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/MapKit/Reference/UIWebView_Class/ A web view is used to embed web content: ● Has delegate <UIWebViewDelegate> to perform methods as web view is about to, starts to, finishes, and fails to load ● Can perform standard methods for displaying and managing web sites (e.g., stopLoading, reload, goForward, goBack) ● Send NSURLRequest via loadRequest: to open web page ● Visually indistinguishable from UIView ● Currently accessory views need to be made manually (e.g., toolbar, buttons, URL bar) UIWebView
  • 36. Indicator Views UIActivityIndicatorView • UIProgressView • UIPageControl
  • 37. Indicator Views UIActivityIndicatorView UIActivityIndicatorView : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/MapKit/Reference/UIActivityIndicatorView_Class/ An activity indicator shows that a task is in progress and appears as a “gear” that is either spinning or stopped: ● Only customization options are color (iOS 5.0 and later) and activityIndicatorViewStyle (either UIActivityIndicatorViewStyleGray, UIActivityIndicatorViewStyleWhite, or UIActivityIndicatorViewStyleWhiteLarge) ● Start and stop animating by calling startAnimating and stopAnimating ● Best used when the length of time is uncertain or indeterminate and cannot be predicted UIActivityIndicatorView
  • 38. Indicator Views UIProgressView UIProgressView : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/MapKit/Reference/UIProgressView_Class/ A progress view visualizes the completion of a task over time: ● Used when the length of time or task length is known ahead of time ● Set progress using method setProgress:animated: as a float between 0.0 and 1.0 ● Customizations include trackTintColor, trackImage, progressTintColor, progressImage, and progressViewStyle UIProgressView (yes, it’s there, I swear!)
  • 39. Indicator Views UIPageControl UIPageControl : UIControl : UIView : UIResponder : NSObject https://developer.apple.com/library/ios/documentation/MapKit/Reference/UIPageControl_Class/ A page control displays a horizontal series of dots, each of which corresponds to a single page or item: ● While UIPageControl is itself a control that you can tap on to change pages, most users will change pages using other methods (e.g., swiping on content) ● Can set hidesForSinglePage to YES if you want UIPageControl not to be visible if only 1 page ● Can set pageIndicatorTintColor and currentPageIndicatorTintColor ● Generally positioned below paginated content ● Custom dots require custom UIPageControl subclass Paginated content UIPageControl
  • 40. Other Topics UIGestureRecognizer • Core Graphics & Core Animation
  • 41. Other Topics UIGestureRecognizer A gesture recognizer is used to recognize a touch event: ● Decouples recognition logic from action logic ● Multiple gesture recognizers can be applied to the same view; however, be aware of how doing so will affect the user experience ○ E.g., if a view has both a tap gesture recognizer and a long press gesture recognizer, how do you distinguish the two? Should the tap gesture be laggy? Or should the long press gesture be delayed? ● Be careful of incomplete gestures UIGestureRecognizer : NSObject https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIGestureRecognizer_Class/ Fast Company © 2012
  • 42. Other Topics Core Graphics & Core Animation https://developer.apple. com/library/mac/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction/Introducti on.html The Core Graphics framework allows you to create your own custom graphics programmatically. ● E.g., Draw polygons, gradients, and lines ● Apply transforms to UIView ● Using Core Graphics instead of image files can make your app faster and leaner The Core Animation framework allows you to create your own custom animations programmatically: ● An animation is defined by its start state, its end state, how long it takes to transition, and how it transitions
  • 43. Example Clock Take a look at your favorite app! How was it built? How many user interface elements can you identify?