我有一個MKMapView
在UITableViewCell
禁用用戶交互。當我滾動UITableViewCell
它刷新所有MKMapViews
。在UITableViewCell中的MKMapView
我讀過這裏的其他答案,一個說不要使用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;
}
安置自己的UITableViewCell繪製代碼,這樣我們就可以看到你在做 – Lefteris
添加了相關的代碼,我的問題是什麼。 – arooo