0

Already checked this question: Weak linking UIPopoverBackgroundView and already read: http://www.marco.org/2010/11/22/supporting-older-versions-of-ios-while-using-new-apis#fnref:1

I have a custom PopoverBackgroundView declared in a .h and implemented in a .m file. Then, in just one file, I instantiate it like this

    self.settingsPopover.popoverBackgroundViewClass = [CustomPopoverBackgroundView class];

I´ve tried doing it like marco says in the link above:

if ([UIPopoverBackgroundView class] != nil) {
    self.settingsPopover.popoverBackgroundViewClass = [CustomPopoverBackgroundView class];
}

But I get the same launch error when I run in a 4.3 ipad simulator

dyld: Symbol not found: _OBJC_CLASS_$_UIPopoverBackgroundView

My base sdk is IOS 5.1, and my target deployment is 5.1 as well. Im using LLVM compiler 4.0.

Any ideas? Thanks a lot!

4

1 回答 1

1

您是否尝试过使用respondsToSelector相关UIPopoverController setBackgroundViewClass方法?请记住,除了普通的属性语法之外,属性会自动生成您可以使用的 setter 和 getter 方法。

您仍然收到链接器错误的原因是因为您仍在尝试调用该类的方法,该方法不存在。

如果是整个类都不存在的情况,Apple 建议使用NSClassFromString(@"UIPopoverController")并检查返回的结果是否为 nil。

于 2012-09-18T09:27:36.967 回答