views:

16

answers:

0

Hi there.

When I first bring up an MKMapView my app seems to pause while it loads. I am assuming this is because it doesn't load asynchronously.

Is there any way I can get around this. While it loads you can't switch tabs or do anything.

Thanks

EDIT: here is my viewDidLoad method:

CGRect bounds = self.view.bounds;
    mapView = [[MKMapView alloc] initWithFrame:bounds];
    mapView.mapType=MKMapTypeStandard;
    mapView.showsUserLocation = YES;
    mapView.delegate = self;

    [self.view insertSubview:mapView atIndex:0];

    NSArray *mapTypes = [NSArray arrayWithObjects:@"Standard",@"Satellite",@"Hybrid",nil];

    mapType = [[UISegmentedControl alloc] initWithItems:mapTypes];
    [mapType setSegmentedControlStyle:UISegmentedControlStyleBar];
    [mapType setCenter:CGPointMake(210, 345)];
    [mapType setSelectedSegmentIndex:0];
    [mapType setTintColor:[UIColor darkGrayColor]];
    [mapType addTarget:self action:@selector(changeType:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:mapType];

    // refresh button...
    UISegmentedControl *refreshButton = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Refresh",nil]] autorelease];
    [refreshButton setSegmentedControlStyle:UISegmentedControlStyleBar];
    [refreshButton setCenter:CGPointMake(self.view.frame.size.width-((refreshButton.frame.size.width/2)+5),(refreshButton.frame.size.height/2)+5)];
    [refreshButton setMomentary:YES];
    [refreshButton setTintColor:[UIColor darkGrayColor]];
    [refreshButton addTarget:self action:@selector(updateMarkers) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:refreshButton];


    UIBarButtonItem *leftBarButton = [[[UIBarButtonItem alloc] initWithTitle:@"List" style:UIBarButtonItemStylePlain target:self action:@selector(goToList)] autorelease];
    [self.navigationItem setRightBarButtonItem:leftBarButton animated:YES];

    // refresh label
    refreshView = [[UIView alloc] initWithFrame:CGRectMake(5, 5, self.view.frame.size.width-74, 40)];
    [refreshView setBackgroundColor:[UIColor colorWithWhite:0 alpha:0.8]];
    [refreshView.layer setCornerRadius:5];
    [self.view addSubview:refreshView];

    UILabel *refreshLabel = [[[UILabel alloc] initWithFrame:CGRectMake(5, 5, refreshView.frame.size.width-10, refreshView.frame.size.height-10)] autorelease];
    [refreshLabel setTextColor:[UIColor whiteColor]];
    [refreshLabel setBackgroundColor:[UIColor clearColor]];
    [refreshLabel setFont:[UIFont fontWithName:@"Helvetica" size:12]];
    [refreshLabel setNumberOfLines:2];
    [refreshLabel setLineBreakMode:UILineBreakModeWordWrap];
    [refreshLabel setText:@"Move the map and press 'refresh' to load new results."];
    [refreshView addSubview:refreshLabel];

    [NSTimer scheduledTimerWithTimeInterval:10 target:refreshView selector:@selector(removeFromSuperview) userInfo:nil repeats:NO];