I retrofitted an alert view and an action sheet into the Still project.
This is the alert view
(of style
UIAlertControllerStyle.Alert
)
that would have been displayed if there was no source from which to pick an image.
An alert view displays a message.
When the user presses OK, it disappears.
This is the action sheet
(of style
UIAlertControllerStyle.ActionSheet
)
that is displayed when there are sources from which to pick an image.
An action sheet asks the user to make a choice,
and then it disappears.
AppDelegate.swift
:
unchanged.
ViewController.swift
View.swift
Info.plist
The
UIAlertController
’s
view is displayed modally (temporarily)
by calling the first view controller’s method
presentViewController(_:animated:completion:)
,
which we saw in
Modal.
This method cannot be called in the first view controller’s
init
,
loadView
,
or
viewDidLoad
methods (but it can be called in
viewDidAppear
).
It can only be called after the first view controller’s view is
displayed in the
window.