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];
}
网友评论