Graphics Programs Reference
In-Depth Information
MapKit Framework
The Core Location framework tells us where we are in the world; the MapKit framework
shows us that world. Most of MapKit's work is done by the class MKMapView . Instances
of this type display a map, track touches, and display annotations. (They can do more, but
that's all you will need for this application.)
First, add the MapKit framework to your project. (If you've forgotten how, flip back to the
beginning of Chapter 4 to refresh your memory.)
You must also import the MapKit header file into files that will use MapKit classes. At the
top of WhereamiViewController.h , import the MapKit header.
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
To determine the necessary instance variables for the WhereamiViewController , re-
view the object diagram in Figure 5.2 . You'll need an MKMapView , a UITextField ,
and a UIActivityIndicatorView . (We'll handle the MKAnnotationView s in a
later section.) Declare these instance variables in WhereamiViewController.h .
@interface WhereamiViewController : UIViewController
<CLLocationManagerDelegate>
{
CLLocationManager *locationManager;
IBOutlet MKMapView *worldView;
IBOutlet UIActivityIndicatorView *activityIndicator;
IBOutlet UITextField *locationTitleField;
}
@end
Recall that IBOutlet means you will create objects in a XIB file. In the project navigat-
or, select WhereamiViewController.xib to open it in the editor area. Then select
the View object in the outline view to show the UIView instance on the canvas, and we
can begin building the user interface.
Search WWH ::




Custom Search