在我的由一个分组的tableView组成的应用程序中,detailTextLabel显示通过日期选择器输入的日期。我使用这个日期从webservice中检索数据。我想要做的是将文本添加到单元格的detailTextLabel中,这样我就可以访问标签的text属性来获取日期并向webservice发送请求。我尝试向detailTextLabel添加标签,如下所示
cell.detailTextLabel = self.fromDate //fromDate is an instance of UILabel;但它显示了我的错误...
我该如何解决这个问题呢?
发布于 2010-07-15 18:35:28
您应该将cell.detailTextLabel.text设置为修改其内容,并可能更改cell.detailTextLabel的布局,但不要尝试将另一个UILabel分配给它。
您可能希望将自己的标签添加为子视图,然后执行以下操作
UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(160.0f,23.0f,150.0f,20.0f)];
lbl.textAlignment = UITextAlignmentRight;
lbl.font = [UIFont fontWithName:@"Arial" size:14.0f];
lbl.textColor = [UIColor lightGrayColor];
lbl.text = [@"Ref.No. " stringByAppendingString:refno];
[cell addSubview:lbl];https://stackoverflow.com/questions/3254647
复制相似问题