3
我想在MKPinAnnotationView的标注内显示一个UITableView。我在故事板文件中添加了UITableViewController。我正在使用以下代码将leftAccessoryView分配给UITableView。在MKPinAnnotationView内显示一个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;
}
PropertyDetailsViewController:
- (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;
}
当我点击它BAD_EXCEPTION什么崩溃的引脚上。
是你的propertyDetailsViewController有效(非零),有效视图? – Marco 2012-07-10 17:53:21
properyDetailsViewController是有效的,它在Storyboard中。我用PropertyDetailsViewController更新了代码。很少有可能成为兴趣点的方法。 – azamsharp 2012-07-10 17:57:19
让我尝试使用UIPopUPController并在其中显示tableview。 – azamsharp 2012-07-10 18:09:25