Вопрос

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!

Это было полезно?

Решение

Have you tried using respondsToSelector with the relevant UIPopoverController setBackgroundViewClass method? Remember that properties automatically generate setter and getter methods that you can use in addition to the normal property syntax.

The reason why you're still getting linker errors is because you're still trying to call a method on that class, which doesn't exist.

If it's a case that the entire class doesn't exist, Apple recommends using NSClassFromString(@"UIPopoverController") and checking if the returned result is nil.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top