iOS中xib文件添加约束的按钮不见了,怎么设置回来
展开全部
1.加载RowView.xib文件,创建Objects下面的所有控件:
NSArray *views = [[NSBundle mainBundle] loadNibNamed:@"RowView" owner:nil options:nil];
2.取出xib中的第一个子控件:
UIView *rowView = views[0];
3.设置头像
UIButton *icon = (UIButton *)[rowView viewWithTag:1];
NSString *iconName = [NSString stringWithFormat:@"01%d.png", arc4random_uniform(9)];
[icon setImage:[UIImage imageNamed:iconName] forState:UIControlStateNormal];
4.设置姓名
UILabel *name = (UILabel *)[rowView viewWithTag:2];
name.text = _allNames[arc4random_uniform(_allNames.count)];
5.监听删除按钮
UIButton *delete = (UIButton *)[rowView viewWithTag:3];
[delete addTarget:self action:@selector(deleteClick:) forControlEvents:UIControlEventTouchUpInside];
NSArray *views = [[NSBundle mainBundle] loadNibNamed:@"RowView" owner:nil options:nil];
2.取出xib中的第一个子控件:
UIView *rowView = views[0];
3.设置头像
UIButton *icon = (UIButton *)[rowView viewWithTag:1];
NSString *iconName = [NSString stringWithFormat:@"01%d.png", arc4random_uniform(9)];
[icon setImage:[UIImage imageNamed:iconName] forState:UIControlStateNormal];
4.设置姓名
UILabel *name = (UILabel *)[rowView viewWithTag:2];
name.text = _allNames[arc4random_uniform(_allNames.count)];
5.监听删除按钮
UIButton *delete = (UIButton *)[rowView viewWithTag:3];
[delete addTarget:self action:@selector(deleteClick:) forControlEvents:UIControlEventTouchUpInside];
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询