我有UITableViewController
,我需要更新UILabel
值。 UITableView
包含部分。如何在TableView的左侧创建UILabel以获取更新单元格值。因为当我创建NSArray
时它正在更新表右侧的值,我无法在TableView中为标签添加xib。所以请解释如何添加UILabel
。它需要添加或任何其他可能性。
答案 0 :(得分:0)
要创建UILabel programmaticaly,代码:
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, 200, 100)];
要在UILabel中显示文本,请使用: myLabel.text = @“Lorem ......”;
当然要将UILabel添加到您的视图中:
[self.tableview addSubview:myLabel];
默认情况下,UILabel有白色背景,您可以轻松删除背景或更改颜色:
myLabel.backgroundColor = [UIColor clearColor];
答案 1 :(得分:0)
我认为你需要在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
并做
cell.detailTextLabel.text = [yourArray objectAtIndex:indexPath.row];
Docs。祝你好运