iOS多代理实现

http://www.cocoachina.com/ios/20151208/14595.html

//实现原理

https://www.jianshu.com/p/961cfc9a446b

 

写一个中间桥接管理类,管理所有的delegate

使用方法:

  SVHomeCycleDelegateObj *obj = [[SVHomeCycleDelegateObj alloc] init];
    self.obj = obj;
    @weakify(self);
//多个代理
    self.multidelegate = [[NVMMultidelegate alloc] init]; //中间delegate管理类
    
    SVHomeCycleScrollView *cycleScrollView = [SVHomeCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, WIDTH_WITH6(17)+self.safeTop, Main_Screen_Width, header.height - (WIDTH_WITH6(17)+self.safeTop)) delegate:self.multidelegate placeholderImage:nil];
    cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleNone;
    cycleScrollView.backgroundColor = [UIColor colorWithWhite:0.f alpha:0];
    cycleScrollView.infiniteLoop = YES;
    [header addSubview:cycleScrollView];
    self.cycleScrollView = cycleScrollView;
    
    [self.multidelegate addDelegate:obj];
    [self.multidelegate addDelegate:self];

猜你喜欢

转载自www.cnblogs.com/tufei7/p/10826684.html