开发者

"Symbol not found" error for UIPopoverController in an iPhone/iPad Universal App

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.

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 开发者_StackOverflow中文版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

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?


Ahhhh nevermind. Check out Apple's example app "TopPaid"

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];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜