iOS3 设备上的 iOS4 代码
是否可以在应用程序中包含 iOS4 特定代码(即 MKMapView 覆盖),使用 4.0 构建,将部署目标设置为 3.0,并且只要不在 3.x 设备上调用 iOS4 代码,它仍然可以工作?
我现在正在尝试这样做,并且仅在设备支持的情况下调用 iOS4 代码,但我无法安装它。 GDB彻底崩溃了以下是我为 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.
我希望此应用程序在 3.0 及更高版本上运行,并在 4.0 设备上使用新的 MKMapView 叠加层。
具体来说,我正在实现 WWDC 上演示的平铺图像叠加代码,该代码使用实现 MKOverlay
协议的自定义 TileOverlay
和自定义 TileOverlayView
它是 MKOverlayView 的子类。
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?
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. GDB is freaking out. Here's what I get when I build for an iOS3 device:
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.
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
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将 Base SDK 设置为 4.0,将 Deployment Target 设置为 3.0 进行构建。
然后,当尝试使用仅存在于 4.0 中的类时,请使用 NSClassFromString("MKOverlayView") 或任何名称。如果该类不存在,则返回 nil。
Matt Gallagher 的这篇文章针对这种情况提供了更详细的提示:
http://cocoawithlove.com/2010/07/tips-tricks-for-conditional-ios3-ios32.html
You need to build with the Base SDK set to 4.0 and the Deployment Target set to 3.0.
Then, when trying to use a class that only exists in 4.0, use NSClassFromString("MKOverlayView") or whatever it's called. That will return nil if the class doesn't exist.
This post from Matt Gallagher has more detailed tips for this kind of situation:
http://cocoawithlove.com/2010/07/tips-tricks-for-conditional-ios3-ios32.html
尝试弱链接 MapKit 框架。
Try weak linking the MapKit framework.