2009-07-03 14 views
0

私は数日間これに固執されており、誰かが手がかりを持っていたのだろうかと疑問に思っていましたか?シンプルにする必要がありますが、それは私が立ち往生している!私は自分の位置を取得し、次に続行します。しかし、私は有効な場所を得るまで、その方法 - ループ - にとどまりたいです。その後、loadview。何かヒントありがとうございます!loadview私のGPS位置を取得するときのみ

私は標準を使用しています:

- (id)init 
{ 
    if (self = [super init]) 
    { 
     self.locationManager = [[[CLLocationManager alloc] init] autorelease]; 
     self.locationManager.delegate = self; // send loc updates to myself 
     self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
     [self.locationManager startUpdatingLocation]; 
    } 

    return self; 
} 



- (void)viewDidLoad 
{ 


// do my processing here ONLY when I get a valid location*************************** 
// and if I never get a valid location, then just go to my last location. 



} 



(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 
{ 
    NSDate* eventDate = newLocation.timestamp; 
    NSTimeInterval howRecent = [eventDate timeIntervalSinceNow]; 

    if (abs(howRecent) < 5.0) 

    { 

     [manager stopUpdatingLocation] 

     printf("latitude %+.6f, longitude %+.6f\n", newLocation.coordinate.latitude, newLocation.coordinate.longitude); 

    } 


} 

答えて

3

のではなく、あなたのviewDidLoadで回転し、一時的なビューを置くことについて、あなたのGPSの場所を持ってまで、どのように?

// custom full-screen view class of your choice 
// could just be a UIImageView if you wanted 
SplashOverlay *splash; 

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    splash = [[SplashOverlay alloc] initWithNibName:@"SplashOverlay" bundle:nil]; 

    [self.view addSubview:splash.view]; 
} 

// do this code to get rid of the view 
- (void) doneWithSplashScreen { 
    [splash.view removeFromSuperview]; 
    [splash release]; 
    splash = nil; 
} 

あなたのビューはまだスプラッシュ画面の下に待機していますが、誰もあなたが準備ができるまでそれを操作することはできません。