English 中文(简体)
马图VIew的垃圾
原标题:Crash in MapVIew

我在装上一张,上面有几张皮条,根据共同地址投放。 直到现在为止,我一直对地图表开放一段时间(2分钟)。 然后它坠毁,实际上没有发生任何事件。 原因何在。

在我看来,DidLoad I撰写了以下法典:

 mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
    mapView.delegate=self; 

    [self.view addSubview:mapView]; 

    addressbook = ABAddressBookCreate();
    for (i = 0; i<[groupContentArray count]; i++) {
         NSLog(@"group content array %@", groupContentArray);
        person = ABAddressBookGetPersonWithRecordID(addressbook,[[groupContentArray objectAtIndex:i] intValue]);
        NSLog(@"Person %@", person);
        ABMultiValueRef addressProperty = ABRecordCopyValue(person, kABPersonAddressProperty);
        NSArray *address = (NSArray *)ABMultiValueCopyArrayOfAllValues(addressProperty);
        NSLog(@"Address %@", address);
        for (NSDictionary *addressDict in address) 
        {
            addAnnotation = nil;
            firstName = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty); 
            lastName = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty); 

            NSString *country = [addressDict objectForKey:@"Country"];
            NSString *streetName = [addressDict objectForKey:@"Street"];
            NSString *cityName = [addressDict objectForKey:@"City"];
            NSString *stateName = [addressDict objectForKey:@"State"];

            if (streetName == (id)[NSNull null] || streetName.length == 0 ) streetName = @"";
            if (stateName == (id)[NSNull null] || stateName.length == 0 ) stateName = @"";
            if (cityName == (id)[NSNull null] || cityName.length == 0 ) cityName = @"";
            if (country == (id)[NSNull null] || country.length == 0 ) country = @"";


            NSString *fullAddress = [streetName stringByAppendingFormat:@"/%@/%@/%@", cityName, stateName, country];
            mapCenter = [self getLocationFromAddressString:fullAddress];
            if(stateName != NULL || country != NULL || streetName != NULL || cityName != NULL){

                if ((mapCenter.latitude == 0) && (mapCenter.longitude == 0))
                {
                    //Alert View                    
                }
                else{

                if(addAnnotation == nil){
                    addAnnotation = [[[MyAddressAnnotation alloc] initWithCoordinate:mapCenter title:firstName SubTitle:lastName Recordid:[groupContentArray objectAtIndex:i] ]autorelease];

                    [mapView addAnnotation:addAnnotation];}
                else{
                    //     ALert View                 

                }
                }
            }
        }
        CFRelease(addressProperty);

    }
    [self zoomToFitMapAnnotations:mapView];


    [self.navigationItem setHidesBackButton:YES animated:YES];
    NSString *mapTitle = localizedString(@"MAP_TITLE");
    [self setTitle:mapTitle];
    [segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
最佳回答

在交易法中将地图代表排到零,解决了我的问题。

问题回答

Try this: - (void)viewDidLoad { [super viewDidLoad];

UIImageView *topBar = [[UIImageView alloc] initWithImage:[UIImage    imageNamed:@"header1.png"]];
topBar.frame = CGRectMake(0, 0, 320, 44);
[self.navigationController.navigationBar insertSubview:topBar atIndex:0];
[topBar release];

self.navigationController.navigationBarHidden=YES;

[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
[mapView setShowsUserLocation:YES];
MKCoordinateRegion region = { {0.0, 0.0 iii, { 0.0, 0.0 iii iii; 
region.center.latitude = [strLat doubleValue];
region.center.longitude = [strLong doubleValue];
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[mapView setRegion:region animated:YES]; 

[mapView setDelegate:self];

mapAnonotationView *ann = [[mapAnonotationView alloc] init]; 
ann.title = name;
ann.subtitle = Address; 
ann.coordinate = region.center; 
[mapView addAnnotation:ann];
[ann release];
ann = nil;  

iii

我与我的Pi4S和Orsole一起坠毁,暴露了该区域的南面价值。 在试图从SO中找到大约7个不同的解决方案以及Ampap DTS的各种建议之后,我通过取消该地区的ThatFits呼吁,解决了这一问题。 我简单地使用了:

CLLocationDistance visibleDistance = 100000; // 100 kilometers
MKCoordinateRegion adjustedRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, visibleDistance, visibleDistance);

[_mapView setRegion:adjustedRegion animated:YES];

Apparently there is a problem with that regionThatFits method.





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签