zoukankan      html  css  js  c++  java
  • 代理demo

    1-  .h

    #import <UIKit/UIKit.h>
    
    typedef enum {
        HMStatusDetailTopToolbarButtonTypeRetweeted,
        HMStatusDetailTopToolbarButtonTypeComment,
    } HMStatusDetailTopToolbarButtonType;
    
    @class HMStatusDetailTopToolbar, HMStatus;
    
    @protocol HMStatusDetailTopToolbarDelegate <NSObject>
    //代理方法
    @optional
    - (void)topToolbar:(HMStatusDetailTopToolbar *)topToolbar didSelectedButton:(HMStatusDetailTopToolbarButtonType)buttonType;
    @end
    
    @interface HMStatusDetailTopToolbar : UIView
    + (instancetype)toolbar;
    
    @property (nonatomic, weak) id<HMStatusDetailTopToolbarDelegate> delegate;
    @property (nonatomic, assign) HMStatus *status;
    
    @property (nonatomic, assign) HMStatusDetailTopToolbarButtonType selectedButtonType;
    @end

    .m

        // 3.通知代理
        if ([self.delegate respondsToSelector:@selector(topToolbar:didSelectedButton:)]) {
            [self.delegate topToolbar:self didSelectedButton:button.tag];
        }

     实现代理方法:

    #pragma mark - 顶部工具条的代理
    - (void)topToolbar:(HMStatusDetailTopToolbar *)topToolbar didSelectedButton:(HMStatusDetailTopToolbarButtonType)buttonType
    {
        [self.tableView reloadData];
        switch (buttonType) {
            case HMStatusDetailTopToolbarButtonTypeComment: // 评论
                [self loadComments];
                break;
                
            case HMStatusDetailTopToolbarButtonTypeRetweeted: // 转发
                [self loadRetweeteds];
                break;
        }
    }
    IOS开发
  • 相关阅读:
    RandomAccessFile类
    IO_ObjectOutputStream(对象的序列化)
    IO流_文件切割与合并(带配置信息)
    IO流_文件切割与合并
    IO流_SequenceInputStream(序列流)
    10-stack
    9-queue
    16-两种方法全排列
    8-全排列next_permutation
    15-Call to your teacher(有向图的连通判断)
  • 原文地址:https://www.cnblogs.com/luanmage/p/4623588.html
Copyright © 2011-2022 走看看