开发者

Working with iPhone OS 3.2 only classes

How would you write a universal app that uses classes introduced in iPhone OS 3.2, such as UIPopoverController and UISplitViewController? On Jeff LaMarche's blog about this, Ole provides a method for instantiating these objects; you would instantiate a UIPopoverController like so: [NSClassFromString(@"UIPopoverController") alloc].

This is fine for instantiating these classes in code but what about protocols and their methods? My iPad app uses a UISplitViewController and has a class that needs to conform to the UISplitViewControllerDelegate and UIPopoverControllerDelegate. How would you declare this? And how would you work with a method such as the following?

- (void)splitViewController:(UISplitViewController 开发者_运维知识库*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc

where the method call requires UISplitViewController to be passed in?


You can leave it there, since these UISplitViewController* etc only serves as a type for the compiler to do type-checking (unlike [UISplitViewController alloc] which an actual symbol needs to be linked).

Add a @class UISplitViewController, UIPopoverController; at the start of the file if it doesn't compile.


And, just like that, I see that this isn't a problem if you weak-link the UIKit framework. I found this right here on Stack Overflow.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜