基本上我已經很久沒有 CODING 了, 所以應該回答不了各位的問題. 1. FLYER 載點更新... (天, 我機器都送人了) 2. 亂七八糟的破解問題.... 小弟老了.. 找年輕人去吧 哈哈~~~ ^^!
2011年9月30日 星期五
IPHONE 數位羅盤...
原來IPHONE 的名字叫磁力測量. 難怪找了全世界的 SAMPLE CODE 都沒看到 COMPASS 這個關鍵字. 歐萊利的書真的比較適合東方人 哈哈
Using the Digital Compass
In addition to the accelerometer, the iPhone 3GS has a magnetometer that acts as a
digital compass. Combining the heading (yaw) information (see Figure 10-9) returned
by this device with the roll and pitch information returned by the accelerometer will
let you determine the true orientation of the iPhone in real time.
Figure 10-9. Using the magnetometer (a.k.a. the digital compass) in the iPhone 3GS, you can
determine the heading (yaw) of the device
You should be aware that the magnetometer is measuring the strength of the magnetic
field surrounding the device. In the absence of any strong local fields, these measurements
will be of Earth’s ambient magnetic field, allowing the device to determine its
“heading” with respect to the geomagnetic North Pole. The geomagnetic heading and
true heading, relative to the geographical North Pole, can vary widely (by several tens
of degrees depending on your location).
As well as reporting the current location, the CLLocationManager class can, in the case
where the device’s hardware supports it, report the current heading of the device. The
following code will create an instance of the class, and will send both location and
heading update messages to the designated delegate class:
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
if( locationManager.locationServicesEnabled &&
locationManager.headingAvailable)
{
272 | Chapter 10: Using Sensors
[locationManager startUpdatingLocation];
[locationManager startUpdatingHeading];
} else {
NSLog(@"Can't report heading");
}
It’s even more important to check whether heading information is available than it
is to check whether location services are available, as the availability of heading
information is currently restricted to iPhone 3GS devices only.
We can filter these update messages based on an angular filter. Changes in heading of
less than this amount will not generate an update message to the delegate:
locationManager.headingFilter = 5; // 5 degrees
The default value of this property is kCLHeadingFilterNone. Use this value if you want
to be notified of all heading updates.
The CLLocationManagerDelegate protocol offers a method that is called when the heading
is updated:
- (void)locationManager:(CLLocationManager*)manager
didUpdateHeading:(CLHeading*)newHeading
{
// If the accuracy is valid, process the event.
if (newHeading.headingAccuracy > 0)
{
CLLocationDirection theHeading = newHeading.magneticHeading;
// Do something with the event data.
}
}
If location updates are also enabled, the location manager returns both true heading
and magnetic heading values. If location updates are not enabled, the location manager
returns only the magnetic heading value:
CLLocationDirection trueHeading = newHeading.trueHeading;
As I mentioned previously, the magnetometer readings will be affected by local magnetic
fields, so the CLLocationManager will attempt to calibrate its heading readings by
displaying a heading calibration panel before it starts to issue update messages. However,
before it does so, it will call the locationManagerShouldDisplayHeadingCalibra
tion: delegate method:
- (BOOL)locationManagerShouldDisplayHeadingCalibration:
(CLLocationManager *)manager {
... code not shown ...
}
If you return YES from this method, the CLLocationManager will proceed to display the
device calibration panel on top of the current window. The calibration panel prompts
the user to move the device in a figure-eight pattern so that Core Location can distinguish
between Earth’s magnetic field and any local magnetic fields. The panel will
Using the Digital Compass | 273
remain visible until calibration is complete or until you dismiss it by calling the
dismissHeadingCalibrationDisplay: method in the CLLocationManager class.
2011年9月28日 星期三
MAC OS 10.7 Lion 真的有點難裝....
目前試過很多版本. 在 VIRTUAL BOX 下基本上都會出現 ERROR. 說 MAC OS 不能支援這個平台.
於是呢, 又找了 PRE INSTALLED 的 IMAGE 再試試. 灰色的 APPLE LOGO 出現了. 結果還是死掉
再來呢, 我們找 PRE INSTALLED VMWARE IMAGE WITH VMWARE 版的. 居然要 5.6 G....
在這個網路環境這麼差的地方, 應該要下傳個一天.
無奈中.... 看起來 似乎 MAC OS 確實鎖了很多. 以 VM 模式執行, 還真的需要時間去了解....
===
二天前順利的 "黑" 了蘋果的 MAC LION 系統. 並且順利裝上 XCODE. 過程呢.... 有點複雜.
A. 要有 VMWARE. 如果使用 VIRTUALBOX. 必須要用 USB 碟載入.
B. MACOS 無法直接安裝. 必須先"模擬" 出一個假的 MAC開機系統. 之後才能裝
C. GOOGLE 上的所有資源. 或多或少都有 BUG.
因為檔案太大了. 所以就不分享了. 我只也打算寫完 IPHONE 支援程式後, 就砍掉了.
於是呢, 又找了 PRE INSTALLED 的 IMAGE 再試試. 灰色的 APPLE LOGO 出現了. 結果還是死掉
再來呢, 我們找 PRE INSTALLED VMWARE IMAGE WITH VMWARE 版的. 居然要 5.6 G....
在這個網路環境這麼差的地方, 應該要下傳個一天.
無奈中.... 看起來 似乎 MAC OS 確實鎖了很多. 以 VM 模式執行, 還真的需要時間去了解....
===
二天前順利的 "黑" 了蘋果的 MAC LION 系統. 並且順利裝上 XCODE. 過程呢.... 有點複雜.
A. 要有 VMWARE. 如果使用 VIRTUALBOX. 必須要用 USB 碟載入.
B. MACOS 無法直接安裝. 必須先"模擬" 出一個假的 MAC開機系統. 之後才能裝
C. GOOGLE 上的所有資源. 或多或少都有 BUG.
因為檔案太大了. 所以就不分享了. 我只也打算寫完 IPHONE 支援程式後, 就砍掉了.
訂閱:
文章 (Atom)