- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试在 MKPinAnnotationView 的标注内显示一个 UITableView。我在 Storyboard 文件中添加了 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;
}
属性详细信息 View Controller :
- (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 *propertyDetailsViewController = (PropertyDetailsViewController *) [self.storyboard instantiateViewControllerWithIdentifier:@"PropertyDetailsIdentifier"];
返回一个autoreleased PropertyDetailsViewController。稍后您只需将其 View 分配给标注附件 View ,但没有人保留 View Controller 。儿子,当方法完成时,viewcontrollers 保留计数为零并且它被释放。当访问该 View Controller 上的任何内容时,将引发 BAD_EXCEPTION。
实际上,BAD_EXCEPTION 通常是内存问题(释放太多,两个自动释放等)。可以更好地跟踪激活“启用僵尸对象”标志。这使得对象不会被完全释放,因此您可以看到哪个失败了。
关于ios - 在 MKPinAnnotationView 中显示一个 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11418974/
我正在开发一个 OSX 应用程序。 我对 MKAnnotation 进行了子类化: import Foundation import MapKit class LocationAnnotation:
我想设置自定义图像而不是 map 上的普通图钉。我还希望它能够打开并为每个添加放置动画。 有什么建议吗? 编辑:这是我所拥有的一切 - (MKAnnotationView *)mapView:(MKM
根据 Apple 文档,MKPinAnnotationView 的图钉颜色有红色、绿色和紫色。还有什么办法可以得到其他颜色吗?我在文档中没有找到任何内容。 最佳答案 更多;) 还有原来的: 代码: -
我不明白为什么(理论上)与 MKPointAnnotation 关联的 MKPinAnnotationView 没有出现在 map 上。事实上,图钉出现了,但它不是应有的紫色... 这是代码: MKP
我正在使用 iOS Mapkit 来放置代表包的图钉。初始负载时一切正常。 我需要做的是,当用户位置在最近包裹的100m半径内时,我需要将引脚更改为“解锁”状态(目前可能只是更改颜色)。我已经检测到最
我有以下代码可以在我的 map 中删除并添加新图钉: - (IBAction)setLocation:(id)sender{ NSMutableArray *toRemove = [NSMut
我过去有过使用 MKMapView 和 MKPointAnnotation 的经验,我用它们在 map 上放置了一些图钉。这次我尝试更进一步,使用 MKPinAnnotationView 来编写标签和
编辑:将标题从:“Double tap ..”更改为“Double selection touch..” 我需要在我的应用程序中至少检测到对 MKPinAnnotationView 的第二次触摸。目前
我必须为不同的引脚设置自定义图像。使用我的代码,我可以为它们中的每一个设置自定义颜色,但是当我尝试设置自定义图像而不是颜色时,它不起作用。 - (MKAnnotationView *)mapView:
我想要一个 MKMapView 显示带有公开按钮的注释,这会导致像 the Golden Gate Bridge annotation in this Apple sample app 这样的 Vie
为 MKPinAnnotationView 上传自定义图像后,我注意到图钉偏离了中心。引脚应该位于路线折线上的一个点上,并且位于 mkcircle 的中心;但是,图钉似乎位于多段线的右侧和中心偏北的位
有谁知道为什么用于 MKPinAnnotationView 的图像应该稍微偏移(向上和向右),我使用的代码是: pinView = [[MKPinAnnotationView alloc] initW
MKPinAnnotationView pin 的宽度和高度是多少像素? 编辑:更具体地说,是 iPhone 屏幕上包含图钉的假想矩形的宽度和高度。 最佳答案 根据下面的代码,图钉图像和 MKPinA
我继承了一个引发此警告的项目 Incompatible pointer types assigning to 'MKPinAnnotationView *' from 'MKAnnotationVie
我正在尝试在 MKPinAnnotationView 后面添加图像。看起来在这里执行此操作应该相当容易: - (void)mapView:(MKMapView *)mapView didAddAnno
我添加了 MKPinAnnotationView 和 setDragAble。我的代码在这里 - (MKAnnotationView *)mapView:(MKMapView *)mapView vi
我正在使用 MKPinAnnotationView在我的应用程序中。 我正在设置 MapView对象作为委托(delegate),并使用此代码自定义我的 AnnotationView func
我遇到了一个奇怪的问题,即初始的一组图钉未显示自定义图像。 在我的 - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotati
我正在尝试根据某些条件为 MKPinAnnotationView 创建三个自定义图钉图像注释。在这种情况下,我将遍历自行车站对象的 for 循环,检查可用自行车的数量是否为 0,如果是,则设置一个 p
我过去有一些使用 MKMapView 和 MKPointAnnotation 的经验,我曾用它们在 map 上放置一些图钉。这次我想更进一步,使用 MKPinAnnotationView 来写一个标签
我是一名优秀的程序员,十分优秀!