【发布时间】:2013-12-05 23:08:19
【问题描述】:
我使用 for 循环创建了按钮。按钮做得非常好。现在我必须对所有动态按钮进行单一的 IB 操作。我也设置了标签。我正在使用的代码如下所示。但该操作并未确定我要使用的确切按钮。
for (int i=0; i < 10; i++){
btnphoto=[[UIButton alloc]initWithFrame:CGRectMake(10,(30*i)+110,50,20)];
[btnphoto setTitle:@"Photo" forState:UIControlStateNormal];
[btnphoto addTarget:self action:@selector(someMethod:)forControlEvents:UIControlEventTouchUpInside];
btnphoto.tag=100 + i;
[self.view addSubview:btnphoto];
}
-(void)someMethod:(UIButton *)sender{
}
【问题讨论】: