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];
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询