美文网首页
点击自定义button,push到ViewController

点击自定义button,push到ViewController

作者: 那一处风景ljz | 来源:发表于2016-07-25 13:22 被阅读39次

    view.h中:

    typedef void (^deliverViewBlock)(NSInteger);
    @property(nonatomic,copy)deliverViewBlock deliverViewBlock;
    

    view.m中
    button 的点击方法

    - (void)btnClickCenter:(UIButton *)sender{
    
                //block 实现从自定义view push到指定VC
                if (_deliverViewBlock) {
                    _deliverViewBlock(sender.tag);
    }
    }
    

    VC中

    View *view = [[View alloc]init];
    view.deliverViewBlock = ^(NSInteger centerBtnTag){
    
                NSLog(@"---------%ld",centerBtnTag);
                [self pushToDetailViewController];
    }
    
    - (void)pushToDetailViewController{
        OtherViewController *vc =  [[OtherViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
    

    相关文章

      网友评论

          本文标题:点击自定义button,push到ViewController

          本文链接:https://www.haomeiwen.com/subject/ppbgjttx.html