iOS为不同的button添加不同的方法

       x_button = x_space + line * (x_space + buttonWidth);

        y_button = y_space + row * (y_margin + buttonHeight);

        NSString *title = dicArray[i][@"title"];

        NSString *imageStr = dicArray[i][@"image"];

        SEL selector = NSSelectorFromString(selectorArray[i]); // 反射机制,只要添加方法名的字符串,就能获得方法

        HHSetButton *button = [HHSetButton buttonWithType:UIButtonTypeCustom];

        [button addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside];

原文地址:https://www.cnblogs.com/1018475062qq/p/7018711.html