“未找到符号” iPhone / iPad通用应用程序中的UIPopoverController错误 [英] "Symbol not found" error for UIPopoverController in an iPhone/iPad Universal App
问题描述
在我的通用二进制iPhone / iPad应用程序中,用户可以在模态呈现的视图控制器中调整首选项。
在iPhone上,设置面板显示presentModalViewController:animated:,在iPad上,我使用UIPopoverController。
In a universal binary iPhone/iPad app of mine, users are able to adjust preferences in a view controller that's presented modally. On the iPhone, the settings panel is presented with presentModalViewController:animated:, and on the iPad, I use a UIPopoverController.
我有点哎呀一段时间完全隔离UIPopoverController代码远离iPhone代码。每次我为iPhone编译时,都会出现以下错误:
I'm having a heck of a time completely isolating the UIPopoverController code away from the iPhone code. Everytime I compile for the iPhone, I get the following error:
dyld: Symbol not found: _OBJC_CLASS_$_UIPopoverController
Referenced from: /var/mobile/Applications/CBB37F87-AA6D-47E2-823A-E259E3268A32/MyApp debug.app/MyApp
Expected in: /System/Library/Frameworks/UIKit.framework/UIKit
这当然是因为iPhone上的UIKit没有UIPopoverController类。有没有人建议如何有效地隔离iPad API包含的iPhone代码,所以我实际上可以运行我的代码?
This is of course because UIKit on the iPhone doesn't have a UIPopoverController class. Does anybody have advice for how to effectively isolate the iPad API includes from the iPhone code, so I can actually run my code?
推荐答案
啊,没关系。查看Apple的示例应用程序TopPaid
Ahhhh nevermind. Check out Apple's example app "TopPaid"
这有点hacky,但它确实有效。希望有一个更优雅的解决方案...
It's kinda hacky, but it works. Wish there was a more elegant solution...
Class cls = NSClassFromString(@"UIPopoverController");
if (cls != nil)
{
UIPopoverController *aPopoverController =
[[cls alloc] initWithContentViewController:self.masterViewController];
self.popoverController = aPopoverController;
[aPopoverController release];
[popoverController presentPopoverFromBarButtonItem:barButtonItem
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
}
这篇关于“未找到符号” iPhone / iPad通用应用程序中的UIPopoverController错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!