How to make a universal app (iPad and iphone 4.1) runs on iPod 3.1.3
I am building a universal for iphone/ipad and I already set the deployment target to 3.0. It can run well on iPad 3.2 and iphone 4.1. However, when I build and run it on my iPod 3.开发者_运维技巧1.3, the runtime automatically picks the iPad code path and tell me that it cannot find UIPopOverController and UIMenuItem. In my iPhone path code, I don't use anything like that.
It builds successfully and only when trying to run, it says error and cannot find:
dyld: Symbol not found: _OBJC_CLASS_$_UIPopoverController
Referenced from: /var/mobile/Applications/My_APP
Expected in: /System/Library/Frameworks/UIKit.framework/UIKit
Editted :
If I remove all of my iPad classes and set the App.info Main nib bundle to be iphone only. Then, it works well. I think the problem is that it runs the iPad code. I don't know what's wrong with my iPod or my project
You need to make runtime tests for the classes that are not present on 3.1.3. You cannot have any code like [UIPopoverControler alloc], and you must weaklink to the frameworks.
See answers to this question:
How should I approach building a Universal iOS app that will include iOS 4 features, even though the iPad doesn't yet run iOS 4?
(The question is different to yours, but the root problem is the same one.)
Or this article:
http://cocoawithlove.com/2010/07/tips-tricks-for-conditional-ios3-ios32.html
If you simply want to get around the compile time problems since that device will never the code in question then you can just call the popover etc classes this way:
Class infopopclass = NSClassFromString(@"UIPopoverController");
if(infopopclass) {
id infopop = [[infopopclass alloc] initWithContentViewController:myPopViewController];
[infopop presentPopoverFromRect:CGRectMake(20, 70, 10, 10) inView:self.view permittedArrowDirections:4 animated:YES];
}
精彩评论