The app gives you only one chance to pick a photo or video. Don’t press the green camera button in the iPhone simulator. You’ll get the message “photos can only be captured on HW” in the dbg window, and the app will go into an infinite loop.
main.m
CameraAppDelegate
CameraController
CameraController.h
shows that the
CameraController
is three kinds of delegate:
UIActionSheetDelegate
,
UINavigationControllerDelegate
,
and
UIImagePickerControllerDelegate
.
CameraController
.CameraController
creates a plain vanilla
view
with a
yellow
background.CameraController
also creates an
action sheet,
which Nikita showed us in
alert.html.
The
action sheet
contains three buttons,
not counting the Cancel button.
CameraController
)
destroys the action sheet and creates the
UIImagePickerController
.
The
UIImagePickerController
is also a
navigation controller,
so we’ll see a navigation bar
(at least on top of the photo albums and saved photos).
UIImagePickerController
has gotten a picture from the camera,
photo albums, or camera roll,
the
UIImagePickerController
’s
delegate
(which happens to be the
CameraController
)
destroys the
UIImagePickerController
.
The delegate also
displays the picture in an
image view
inside the
CameraController
’s
view.
The
actionSheet:clickedButtonAtIndex:
method of the
CameraController
needs an array of three numbers of type
UIImagePickerControllerSourceType
,
which is another name for
NSUInteger
.
But an Objective-C
array
can only hold objects, not integers.
Instead of encasing each number in an
NSNumber
object
(as we did in
array3.html),
it’s simpler to resort to an array in the language C.
The keyword
static
ensures that the array will be created
only the first time the method is called.
TouchesBegan:withEvent:
method for class
CameraController
.
It will be called whenever the user touches the yellow background.
This method could create another
action sheet.