我正在尝试在MKPinAnnotationView的气泡中显示UITableView。我在我的故事板文件中添加了UITableViewController。我使用以下代码将leftAccessoryView分配给UITableView。
- (MKAnnotationView *)mapView:(MKMapView *)mv viewForAnnotation:(id < MKAnnotation >)annotation
{
if([annotation isKindOfClass:[MKUserLocation class]])
return nil;
NSString *annotationIdentifier = @"ZillowPropertyDetailsIdentifier";
MKPinAnnotationView *propertyDetailsView = (MKPinAnnotationView *) [mv
dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (!propertyDetailsView)
{
propertyDetailsView = [[MKPinAnnotationView alloc]
initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier];
// get view from storyboard
PropertyDetailsViewController *propertyDetailsViewController = (PropertyDetailsViewController *) [self.storyboard instantiateViewControllerWithIdentifier:@"PropertyDetailsIdentifier"];
propertyDetailsView.leftCalloutAccessoryView = propertyDetailsViewController.view;
[propertyDetailsView setPinColor:MKPinAnnotationColorGreen];
propertyDetailsView.animatesDrop = YES;
propertyDetailsView.canShowCallout = YES;
}
else
{
propertyDetailsView.annotation = annotation;
}
return propertyDetailsView;
}
物业详情视图控制器:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
return cell;
}
当我点击这个pin时,它会崩溃并显示BAD_EXCEPTION或其他错误信息。