ios judge the click event of different buttons

The idea of ​​​​judging the click events of different buttons in UIView that are not in a file in IOS

Let's talk about the overall structure process first

  • xib layout file
  • xib's .h file and xib's .m file
  • The main controller that loads the xib layout file

xib layout file

write picture description here

In this layout file, there are mainly two buttons to judge, one is consultation and the other is my surgery which is clicked.

code in .h file

as follows:

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

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

code in .m file

as follows:

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

Code in the main controller file

as follows:

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];
        }

    };

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325686221&siteId=291194637