我禁用MKMapView
了UITableViewCell
用户交互。当我滚动UITableViewCell
它时,它会刷新所有MKMapViews
.
我在这里阅读了其他答案,一个说不要使用dequeueReusableCellWithIdentifier
(我不是),另一个说dealloc
(mapView
我正在使用 ARC)。我不想使用图像。
MKMapView
当我滚动滚动视图时,我应该怎么做才能防止重新加载?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ANFeedCell"];
ANFeedTableViewCell *cell = nil;
if (cell == nil) {
// Load the top-level objects from the custom cell XIB.
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ANFeedTableViewCell" owner:self options:nil];
// Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain).
cell = [topLevelObjects objectAtIndex:0];
MKMapView *mapView = (MKMapView*)[cell viewWithTag:2];
//Takes a center point and a span in miles (converted from meters using above method)
CLLocationCoordinate2D startCoord = CLLocationCoordinate2DMake(37.766997, -122.422032);
MKCoordinateRegion adjustedRegion = [mapView regionThatFits:MKCoordinateRegionMakeWithDistance(startCoord, MilesToMeters(0.5f), MilesToMeters(0.5f))];
[mapView setRegion:adjustedRegion animated:YES];
}
return cell;
}