仅使用 iPhone OS 3.2 类

发布于 2024-08-31 13:40:13 字数 793 浏览 3 评论 0原文

您将如何编写一个使用 iPhone OS 3.2 中引入的类(例如 UIPopoverControllerUISplitViewController)的通用应用程序?在 Jeff LaMarche 的博客中,Ole 提供了一种实例化这些对象的方法;您可以像这样实例化一个 UIPopoverController[NSClassFromString(@"UIPopoverController") alloc]

这对于在代码中实例化这些类来说很好,但是协议及其方法呢?我的 iPad 应用程序使用 UISplitViewController 并有一个需要符合 UISplitViewControllerDelegateUIPopoverControllerDelegate 的类。你会如何声明这一点?您将如何使用如下方法?

- (void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)pc

其中方法调用需要传入 UISplitViewController

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

恍梦境° 2024-09-07 13:40:13

您可以将其保留在那里,因为这些 UISplitViewController* 等仅充当编译器进行类型检查的类型(与实际符号需要的 [UISplitViewController alloc] 不同)被链接)。

如果无法编译,请在文件开头添加 @class UISplitViewController, UIPopoverController;

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.

指尖凝香 2024-09-07 13:40:13

而且,就像这样,我发现如果您弱链接 UIKit 框架,这不是问题。我在 Stack Overflow 上找到了这个。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文