29,028
社区成员
发帖
与我相关
我的任务
分享
- (void)viewDidLoad {
[super viewDidLoad];
for(int i = 0; i < 6; i++){
UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(0, i*130, 100, 30)];
text.tag = (i+1)*100;
[self.array addObject:text];
if(i>=4 && i<6){
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.tag = (i+1)*200;
[btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
}
}
}
- (void) btnClick:(UIButton *)sender{
NSInteger index = sender.tag / 200 - 1;
UITextField *text = self.array[index];
text.text = @"你要设置的值";
}
写了一个大概。控件样式没有写。你自己思路明白了。就很简单了。