2010-08-02 28 views
0

我想在iphone 3gs或iphone4中製作像羅盤一樣的視圖。你知道有人可以從頭開始嗎?我找不到太多關於這個問題的信息......我只想總是在北方畫一個箭頭。 我使用的是iOS 4.0如何在ios4中繪製像iphone 3gs的指南針?

在此先感謝

回答

1

開始走向更新:

if([CLLocationManager headingAvailable]) { 
    CLLocationManager *locationManager = [[CLLocationManager alloc] init]; 

    // myDelegateObject is an instance of a class implementing the CLLocationManagerDelegate protocol 
    locationManger.delegate = myDelegateObject; 
    [locationManager startUpdatingHeading]; 
} 

實現你的類之一的CLLocationManagerDelegate協議 - 尤其是這樣的:

-(void)locationManager:(CLLocationManager*)manager didUpdateHeading:(CLHeading*)heading { 
    // CLLocationDirection is a double typedef 
    CLLocationDirection headingInDegrees = heading.magneticHeading; 

    // you'll have to implement this in some fashion... 
    [myCompassViewController rotateCompassImageToHeading:headingInDegrees]; 
}