各位大神 我动态添加到View上面N个button,但是有个问题在处理他的点击事件的时候如何能判断他的动态点击事件?
- (void)terminalCreateView{ UIView *tView = [[UIView alloc]initWithFrame:CGRectMake(0, kScActionHeight- 49, kScActionWidth, 49)];
tView.backgroundColor = [UIColor grayColor];
[self.view addSubview:tView];
self.tArray = [[NSMutableArray alloc]init];
for (int i = 0; i < _tArray.count; i++) {
_button = [UIButton buttonWithType:UIButtonTypeCustom];
_button = [[UIButton alloc] initWithFrame:CGRectMake(i * kScActionWidth/(_tArray.count),0, kScActionWidth/(_tArray.count), 49)];
_button.tag = 2015+i;
[_button addTarget:self action:@selector(button_click:) forControlEvents:UIControlEventTouchUpInside];
[tView addSubview:_button];
tView.userInteractionEnabled = YES;
}
[_tArray addObject:tView];
}
//点击事件
- (void)button_click:(UIButton *)bth
{
}
- (void)terminalCreateView{ UIView *tView = [[UIView alloc]initWithFrame:CGRectMake(0, kScActionHeight- 49, kScActionWidth, 49)];
tView.backgroundColor = [UIColor grayColor];
[self.view addSubview:tView];
self.tArray = [[NSMutableArray alloc]init];
for (int i = 0; i < _tArray.count; i++) {
_button = [UIButton buttonWithType:UIButtonTypeCustom];
_button = [[UIButton alloc] initWithFrame:CGRectMake(i * kScActionWidth/(_tArray.count),0, kScActionWidth/(_tArray.count), 49)];
_button.tag = 2015+i;
[_button addTarget:self action:@selector(button_click:) forControlEvents:UIControlEventTouchUpInside];
[tView addSubview:_button];
tView.userInteractionEnabled = YES;
}
[_tArray addObject:tView];
}
//点击事件
- (void)button_click:(UIButton *)bth
{
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货