放大带有MKPlacemark的MKMapView时崩溃 [英] Crash when zooming into a MKMapView with a MKPlacemark
问题描述
我正在尝试向地图添加地标.地标是根据完全不在通讯簿之外的地址构建的.
I'm trying to add a placemark to a map. The placemark is built from an address completely outside of Address Book.
我的地标出现在地图上,但是当我尝试捏放大时会崩溃:
My placemark is appearing on the map, but when I try to pinch to zoom in I get a crash:
*** -[CALayer objectForKey:]: unrecognized selector sent to instance 0x4569dc0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[CALayer objectForKey:]: unrecognized selector sent to instance 0x4569dc0'
这是我设置地址的方式:
Here's how I'm setting up the address:
id theAddress = [NSDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithFormat: @"%@ - %@", theAddress1 ? theAddress1 : @"", theAddress2 ? theAddress2 : @""], kABPersonAddressStreetKey,
theCity ? theCity : @"", kABPersonAddressCityKey,
theState ? theState : @"", kABPersonAddressStateKey,
theZip ? theZip : @"", kABPersonAddressZIPKey,
theCountry ? theCountry : @"", kABPersonAddressCountryKey,
nil];
I use the values in the address record to find the coordinate for the address (learned how to do this from this question & answer), then I add it to my map:
[mapView addAnnotation: [[[MKPlacemark alloc] initWithCoordinate: theCoordinate
addressDictionary: theAddress] autorelease]];
崩溃肯定似乎是由此MKPlacemark引起的,就像我注释掉addAnnotation语句一样,代码也不会崩溃.
The crash definitely seems to be caused by this MKPlacemark, as if I comment out the addAnnotation statement the code doesn't crash.
知道发生了什么吗?我想我的地址记录还不够,但是错误消息确实没有帮助.
Any idea what's going on? I'm guessing I haven't got enough in the address record, but the error message is really unhelpful.
推荐答案
您在某处过度释放了NSDictionary对象.找到方法如下:
You're over-releasing an NSDictionary object somewhere. Here's how you find it:
在项目"菜单下,选择编辑活动可执行文件".在参数"选项卡中,将一个项目添加到要在环境中设置的变量:"块中,其名称为NSZombieEnabled
且值为YES
.
Under the Project menu, select 'Edit Active Executable'. In the Arguments tab, add an item to the "Variables to be set in the environment:" block with the name NSZombieEnabled
and the value YES
.
快乐的僵尸狩猎.
这篇关于放大带有MKPlacemark的MKMapView时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!