简体   繁体   English

iOS3设备上的iOS4代码

[英]iOS4 code on iOS3 devices

Is it possible to have iOS4 specific code (ie the MKMapView overlays) in an application, build using 4.0, set the Deployment Target to 3.0, and still have it work so long as the iOS4 code isn't called on a 3.x device? 是否可以在应用程序中使用iOS4特定代码(即MKMapView覆盖),使用4.0构建,将部署目标设置为3.0,并且只要未在3.x设备上调用iOS4代码,它仍然可以工作?

I am trying to do that now, and only calling the iOS4 code if the device supports it, but I can't get it installed. 我现在正尝试这样做,并且只在设备支持的情况下调用iOS4代码,但我无法安装它。 GDB is freaking out. GDB吓坏了。 Here's what I get when I build for an iOS3 device: 这是我为iOS3设备构建时得到的结果:

dyld: Symbol not found: _OBJC_CLASS_$_MKOverlayView
Referenced from: /var/mobile/Applications/1EE8EC13-FA01-43CB-A617-9B5D268ECD13/maps.app/maps
Expected in: /System/Library/Frameworks/MapKit.framework/MapKit

Data Formatters temporarily unavailable, will re-try after a 'continue'. (Not safe to call dlopen at this time.)
mi_cmd_stack_list_frames: Not enough frames in stack.
mi_cmd_stack_list_frames: Not enough frames in stack.

I want this application to run on 3.0 and up, and use the new MKMapView overlay on 4.0 devices. 我希望这个应用程序在3.0及更高版本上运行,并在4.0设备上使用新的MKMapView覆盖。

Specifically, I am implementing the tiled image overlay code demonstrated at WWDC, which uses a custom TileOverlay that implements the MKOverlay protocol, and a custom TileOverlayView which is a subclass of MKOverlayView . 具体地讲,我实现在WWDC证明平铺图像覆盖的代码,它使用自定义TileOverlay实现该MKOverlay协议,和一个自定义TileOverlayView这是一个子类MKOverlayView

You need to build with the Base SDK set to 4.0 and the Deployment Target set to 3.0. 您需要使用Base SDK设置为4.0并将Deployment Target设置为3.0来构建。

Then, when trying to use a class that only exists in 4.0, use NSClassFromString("MKOverlayView") or whatever it's called. 然后,当尝试使用仅存在于4.0中的类时,请使用NSClassFromString(“MKOverlayView”)或其调用的任何内容。 That will return nil if the class doesn't exist. 如果该类不存在,那将返回nil。

This post from Matt Gallagher has more detailed tips for this kind of situation: 来自Matt Gallagher的这篇文章提供了有关此类情况的更详细提示:

http://cocoawithlove.com/2010/07/tips-tricks-for-conditional-ios3-ios32.html http://cocoawithlove.com/2010/07/tips-tricks-for-conditional-ios3-ios32.html

尝试弱链接MapKit框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM