ios判断不同按钮的点击事件

IOS中判断不在一个文件中的继承于UIView中不同按钮的点击事件的思路

先说总体结构流程

  • xib布局文件
  • xib的.h文件和xib的.m文件
  • 加载xib布局文件的主控制器

xib的布局文件

这里写图片描述

在这个布局文件中,主要来判断两个按钮,一个是咨询,一个是我的手术哪个被点击。

.h文件中的代码

如下:

//三个按钮点击方法
- (IBAction)clickBtn:(UIButton *)sender;

typedef void (^PushNewViewController)(UIButton *);
@property (copy, nonatomic) PushNewViewController pushNewViewController;

.m文件中的代码

如下:

- (IBAction)clickBtn:(UIButton *)sender {
    self.pushNewViewController(sender);
}

主控制器文件中的代码

如下:

WeakSelf;
    myDoctorCell.pushNewViewController = ^(UIButton *button){
        if (button.tag == 30) {
            if (link_status < 3) {

//                [weakSelf creatActionSheet:button];
                [weakSelf submitOperationWithDoctor_id:[_myDoctorMutableArray[indexPath.row][@"doctor_id"] integerValue] type_id:1];

            }else{
                [weakSelf.tabBarController setSelectedIndex:2];
            }
        }else if (button.tag == 31){
            ChatViewController *chatController = [[ChatViewController alloc] initWithConversationChatter:chart_name conversationType:EMConversationTypeChat];
            chatController.chatName = true_name;
            chatController.hidesBottomBarWhenPushed = YES;
            [weakSelf.navigationController pushViewController:chatController animated:YES];
        }

    };

猜你喜欢

转载自blog.csdn.net/xiaoxingaiwo/article/details/79991353