当然,我用谷歌搜索并使用了 stackoverflow 中的搜索。
我发现了一些类似的讨论:
无法实例化名为 MKMapView 的类
http://forums.bignerdranch.com/viewtopic.php?f=49&t=490
NSInvalidUnarchiveOperationException:无法解码类对象(UITableViewCellContentView)
...以及很多的副本:)
但是,我没有使用 SDK 3.2,而是使用 5.0(链接的讨论之一表明这是 SDK 3.2 的某些测试版中的错误)。
其他讨论和答案表明 MapKit 框架未正确包含。
我尝试按照这些说明以多种方式包含它。
我仍然收到此错误。 方法中使用的
[super loadView];
它是在我自己的视图控制器的
- (void)loadView {
。视图本身是在 IB 内构建的。除了其他项目之外,还有一个 MKMapView。
我在我的两个 xcode 项目中使用 MKMapView。两者都是在 xcode 3.2 中启动的,现在迁移到 xcode 4。
在其中一个项目中,代码工作正常,而在另一个项目中,我收到此运行时错误。
我没有发现这些项目设置之间有任何显着差异可以向我解释这种不同的行为。
当前的解决方法是删除与地图视图相关的任何代码(和 IB 项目)。但最后我宁愿包括该地图视图,因为它确实有一个目的:)
任何建议都会受到赞赏。
赫尔曼
Of course I googled and used the search within stackoverflow.
I found some similar discussions:
Could not instantiate class named MKMapView
http://forums.bignerdranch.com/viewtopic.php?f=49&t=490
NSInvalidUnarchiveOperationException: cannot decode object of class (UITableViewCellContentView)
... and lots of copies of that :)
However, I am not using SDK 3.2 but 5.0 (one of the linked discussions suggest it was an error in some beta version of SDK 3.2).
The other discussions and answers suggest that the framework MapKit were not included properly.
I tried to include it several ways, following those instructions.
I am still getting this error. It is thown on
[super loadView];
within my own view controller's
- (void)loadView {
method. The view itself is build within IB. Beside other items is has an MKMapView.
I am using MKMapView in two of my xcode projects. Both were started in xcode 3.2 and now migrated to xcode 4.
Within one of the projects the code works fine and in the other one I get this runtime error.
I did not identify any significant difference between these projects' setups that could explain this diffrent behaviour to me.
A current workaround is to take off any code (and IB item) that is relatd to a Map View. But in the end I'd rather include that map view because it does serve a purpose :)
Any suggestion is appreciated.
Hermann
发布评论
评论(2)
使用 Xcode 7.2 添加 Framework 可以通过 3 种方式完成。
1.在目标下选择项目 ->单击常规选项卡 ->展开与库链接的框架 ->单击+图标 ->搜索 MapKit ->单击“添加”。
2.在目标下选择项目 ->点击功能 ->在地图下 -> 点击切换按钮。
3.在目标下选择项目 ->单击构建阶段 ->展开与库链接的框架 ->单击+图标 ->搜索 MapKit ->单击“添加”。
Using Xcode 7.2 adding Framework can be done in 3 ways.
1. Under Targets Select Project -> Click on General Tab -> Expand Linked Frameworks with Libraries -> Click on + icon -> Search For MapKit -> Click on Add.
2. Under Targets Select Project -> Click on Capabilities -> Under Maps -> Click On Switch Button.
3. Under Targets Select Project -> Click on Build Phases -> Expand Linked Frameworks with Libraries -> Click on + icon -> Search For MapKit -> Click on Add.
转到您的目标设置 - 不是项目级别,而是目标级别。单击“构建阶段”,然后展开“链接二进制文件与库”。确保列出了 MapKit.framework,如果没有则添加它。
Go to your target settings - not project level but target level. Click on Build Phases, then expand Link Binary with Libraries. Ensure that MapKit.framework is listed and add it if not.