0

I have been stuck on this for days, and was wondering if anyone had any clues? Should be simple, but it has me stuck! I get my location, then continue. But I want to stay IN THAT METHOD - LOOPING - until I get a valid location. Then loadview. THANKS for any tips!

I am using the standard:

- (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);

    } 


}
Lucas Jones
  • 19,767
  • 8
  • 75
  • 88
Edward Potter
  • 3,760
  • 4
  • 28
  • 39

1 Answers1

3

Rather than spinning in your viewDidLoad, how about putting up a temporary view until you have your GPS location?

// 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;
}

your view will still be under the splash screen waiting, but nobody can interact with it until you're ready.

David Maymudes
  • 5,664
  • 31
  • 34