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

落花浮王杯 提交于 2019-12-08 06:09:47

问题


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 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?


回答1:


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


来源:https://stackoverflow.com/questions/3026871/symbol-not-found-error-for-uipopovercontroller-in-an-iphone-ipad-universal-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!