与Interface Builder的链接较弱 [英] Weak linking with Interface Builder

查看:68
本文介绍了与Interface Builder的链接较弱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序使用3.x SDK功能,但需要在2.x设备中运行。解决方案似乎是使用弱链接,我做了,但应用仍然无法*编译*为iPhone 2.2.1:框架未找到MapKit。

Application uses 3.x SDK feature, but needs to run in 2.x devices. The solution seems to be using "weak linking", which I did, but app still fails to * compile * for iPhone 2.2.1: "Framework not found MapKit".

编译目标Device 3.0 - Debug即可,甚至安装在运行2.2.1的iPod Touch上!只要我没有使用MapKit激活视图就运行正常,如果我没有崩溃。

Compile for target "Device 3.0 - Debug" is ok, even installs on my iPod Touch running 2.2.1! Runs ok as long as I don't activate view using MapKit, crashes if I do.

我使用Interface Builder创建了一个视图,在其上拖动了一个MkMapView对象。据我所知,这是对MapKit的唯一引用,所以问题是:当我使用弱链接时,我可以在IB中使用相关的UI元素吗?我应该只在XCode中完成所有这些吗?猜对了,但是能够在2.2.1设备上安装和运行3.0应用程序会让我困惑......

I created a view using Interface Builder, dragged a MkMapView object on it. As far as I can tell, this is the only reference to MapKit, so the question is: when I use weak linking, can I use related UI elements in IB at all? Should I do all of this in XCode only? Guess yes, but being able to install and run "3.0" app on "2.2.1" device confuses me...

推荐答案

您不应该在2.0设备上加载仅包含3.0对象(如MKMapView)的nib文件。这意味着,您必须从代码中检查您在nib中使用的框架/类的可用性。如果它们不可用,则不得加载笔尖。

You should not load a nib file which contains 3.0 only objects like MKMapView on a 2.0 device. That means, you have to check from code the availability of the framework/classes you use in the nib. If they are not available, you must not load the nib.

这是检查地图套件是否可用的方法:

This is how you can check if map kit is available:

if (NSClassFromString(@"MKMapView") != NULL) {
    // load nib, map kit is available
} else {
    // do something else, map kit is not there
}

这篇关于与Interface Builder的链接较弱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆