【问题标题】:how to define two delegates in the @interface line如何在@interface 行中定义两个委托
【发布时间】:2011-05-19 11:30:10
【问题描述】:

在 iOS 中,我想同时包含一个用于 FlipsideView 的委托(来自实用程序应用程序模板)和一个允许滚动视图的委托。 我的尝试是:

@interface MainViewController : UIViewController 
<FlipsideViewControllerDelegate> <UIScrollViewDelegate> {
 }

我试图在两个 之间放置一个逗号 (,) 或空格,但它不起作用。 有人能够并且愿意帮助我解决这个问题吗?

提前感谢您的帮助

【问题讨论】:

    标签: ios delegates uiscrollview


    【解决方案1】:

    这样做:

    @interface MainViewController : UIViewController 
      <FlipsideViewControllerDelegate, UIScrollViewDelegate> 
    {
    
    }
    

    语法如下:

    @interface 类名:它的超类

    例如对于多个协议:

    @interface 格式化程序:NSObject

    您可以阅读有关协议以及如何使用adopt and conform in Apple's official Documentation 的更多信息。

    【讨论】:

      【解决方案2】:

      只需要一个&lt;&gt;,用逗号分隔协议。

      @interface MainViewController : UIViewController 
      <FlipsideViewControllerDelegate, UIScrollViewDelegate> {
       }
      

      【讨论】:

      • 感谢 Krishnan 的建议,我正在学习 stackoverflow 的功能,并且非常喜欢它。
      猜你喜欢
      • 2016-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-29
      • 2023-03-06
      • 2020-10-09
      • 1970-01-01
      • 2023-03-08
      相关资源
      最近更新 更多