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

posted on 2017-06-15 16:48  1018475062  阅读(117)  评论(0)    收藏  举报