TAILIEUCHUNG - iOS 5 Programming Cookbook phần 6

Đến từ Core và khung Kit Bản đồ có thể được sử dụng để tạo ra địa điểm nhận thức và ứng dụng dựa trên bản đồ. Khuôn khổ Đến từ Core sử dụng phần cứng của thiết bị nội bộ để xác định vị trí hiện tại của thiết bị. Bản đồ Kit khuôn khổ cho phép ứng dụng của bạn để hiển thị bản đồ để người dùng của bạn, | CHAPTER 6 Core Location and Maps Introduction The Core Location and Map Kit frameworks can be used to create location-aware and map-based applications. The Core Location framework uses the internal device s hardware to determine the current location of the device. The Map Kit framework enables your application to display maps to your users put custom annotations on the maps and so on. The availability of location services depends on the availability of hardware on the device if the hardware is there it must be enabled and switched on for the Map Kit framework to work. To use the Core Location and Map Kit frameworks you need to first add them to your project and make sure appropriate header files are imported. Follow these steps to add these two frameworks to your project 1. Click on your project icon in Xcode. 2. Select the target to which you want to add the frameworks to as shown in Figure 6-1. 3. Now select the Build Phases tab on the top Figure 6-1 . 4. Expand the Link Binary With Libraries box Figure 6-1 and press the button. 429 Figure 6-1. Selecting the target to which we want to add the frameworks 5. In the dialog you will see the list of all available frameworks and static libraries. Find and select both the and the and then press Add as shown in Figure 6-2. 430 Chapter 6 Core Location and Maps Figure 6-2. Adding the CoreLocation and the MapKit frameworks to a project After adding these two frameworks you will need to add two header files to your .m or .h file in your .h file if you are referring to any entity that is included in either of the two aforementioned frameworks import CoreLocation import MapKit Creating a Map View Problem You want to instantiate and display a map on a view. Solution Create an instance of the MKMapView class and add it to a view or assign it as a subview of your view controller. Here is the sample .h file of a view controller that creates an instance of .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.