TAILIEUCHUNG - Lập trình ứng dụng cho iPhone part 17

Positioning: accelerometers and location Khi chúng tôi lần đầu tiên giới thiệu iPhone, chúng tôi nêu bật một số tính năng độc đáo của nó. Trong số đó có hai thành phần cho phép của iPhone để tìm ra chính xác nơi mà nó có trong không gian: một bộ ba của gia tốc, trong đó cung cấp cho nó khả năng chuyển động ý nghĩa trong không gian ba chiều, và một thiết bị điểm trên (cách sử dụng hoặc GPS hay GPS faux), trong đó cho phép nó ra con số nơi trên thế giới nó được | Positioning accelerometers and location This chapter covers Measuring gravity Gauging movement Determining location When we first introduced the iPhone we highlighted a number of its unique features. Among them were two components that allow the iPhone to figure out precisely where it is in space a trio of accelerometers which give it the ability to sense motion in three dimensions and a locational device using either GPS or faux GPS which lets it figure out where in the world it is. Other than accessing some basic orientation information we haven t done much with these features. That s because most of the functionality isn t available to the web interface and because it lies beyond the basic concepts of the SDK that we ve covered so far. But now we ll dive into these positioning technologies and examine how to use them in your programming. 324 The accelerometer and orientation 325 We re going to start off with some new ways to look at orientation data and then we ll expand into some original possibilities. The accelerometer and orientation The easiest use of the accelerometers is to determine the iPhone s current orientation. We already used the view controller s interfaceOrientation property back in chapter 13. As we mentioned at the time though you can also access orientation information through the UIDevice object. It can provide more information and realtime access that isn t available using the view controller. There are two ways to access the UIDevice information through properties and through a notification. The orientation property The easy way to access the UIDevice s orientation information is to look at its orientation property. You must first access the UIDevice itself which you can do by calling a special UIDevice class method pretty much the same way you access the UIApplica-tion object UIDevice thisDevice UIDevice currentDevice Once you ve done this you can get to the orientation property. It will return a constant drawn from .

Đã 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.