当添加地图视图时,iPhone应用程序崩溃

4

我正在尝试将MKMapView添加到我的应用程序中,但是当包含它的视图加载时,我的应用程序会崩溃。我甚至尝试创建一个新项目,只需添加地图视图而不编写任何代码,它也会崩溃。

有任何想法是什么原因呢?

在调试器中获得的调用堆栈如下:

#0  0x916a1132 in __kill
#1  0x916a1124 in kill$UNIX2003
#2  0x917338e5 in raise
#3  0x9174999c in abort
#4  0x93f65fda in __gnu_cxx::__verbose_terminate_handler
#5  0x02392333 in _objc_terminate
#6  0x93f6417a in __cxxabiv1::__terminate
#7  0x93f641ba in std::terminate
#8  0x93f642b8 in __cxa_throw
#9  0x02392481 in objc_exception_throw
#10 0x02556238 in +[NSException raise:format:arguments:]
#11 0x025561aa in +[NSException raise:format:]
#12 0x000155eb in _decodeObjectBinary
#13 0x0001646d in -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:]
#14 0x00016a9c in -[NSArray(NSArray) initWithCoder:]
#15 0x0001569c in _decodeObjectBinary
#16 0x00014809 in _decodeObject
#17 0x002e5a3f in -[UIView initWithCoder:]
#18 0x002d2af0 in -[UIWindow initWithCoder:]
#19 0x0001569c in _decodeObjectBinary
#20 0x00014809 in _decodeObject
#21 0x004a4d77 in -[UIRuntimeConnection initWithCoder:]
#22 0x0001569c in _decodeObjectBinary
#23 0x0001646d in -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:]
#24 0x00016a9c in -[NSArray(NSArray) initWithCoder:]
#25 0x0001569c in _decodeObjectBinary
#26 0x00014809 in _decodeObject
#27 0x004a4034 in -[UINib instantiateWithOwner:options:]
#28 0x004a5eb5 in -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:]
#29 0x002b1402 in -[UIApplication _loadMainNibFile]
#30 0x002b231c in -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:]
#31 0x002bc3ec in -[UIApplication handleEvent:withNewEvent:]
#32 0x002b4b3c in -[UIApplication sendEvent:]
#33 0x002b99bf in _UIApplicationHandleEvent
#34 0x02d5d822 in PurpleEventCallback
#35 0x0257eff4 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
#36 0x024df807 in __CFRunLoopDoSource1
#37 0x024dca93 in __CFRunLoopRun
#38 0x024dc350 in CFRunLoopRunSpecific
#39 0x024dc271 in CFRunLoopRunInMode
#40 0x002b1c6d in -[UIApplication _run]
#41 0x002bdaf2 in UIApplicationMain
#42 0x00002774 in main at main.m:14

有什么想法吗?谢谢。

控制台中有任何崩溃描述吗? - Vladimir
没有看到代码,调试代码是非常困难的。 - PengOne
除了创建基于窗口的应用程序时生成的代码之外,没有任何代码! - kman
快速更新一下 - 我遇到了一个异常,原因如下:"***-[NSKeyedUnarchiver decodeObjectForKey:]: 无法解码 (MKMapView) 类的对象"。 - kman
你是否添加了正确的框架?请向我们展示您添加 MapView 的代码... - Sandro Meier
1个回答

17

你可能忘了包含 MapKit 框架。


1
这就是它将会变成的样子。几天前在一个新项目上我也遇到了同样的问题,让我苦恼了一段时间,直到恍然大悟! - Roger
是的,你说得对,我刚刚看到了这个链接:http://cs491f09.wordpress.com/2009/10/30/assignment-6-adding-the-mapkit-framework/ 按照那里的说明操作,它可以正常工作 - 谢谢! - kman
我之前遇到了相同的问题,但我发现这个链接(来自苹果)更有用:http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/LocationAwarenessPG/MapKit/MapKit.html#//apple_ref/doc/uid/TP40009497-CH3-SW1 - Raymond

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接