Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 将UILabel添加到UITableViewCell的detailTextLabel_Iphone_Uilabel - Fatal编程技术网

Iphone 将UILabel添加到UITableViewCell的detailTextLabel

Iphone 将UILabel添加到UITableViewCell的detailTextLabel,iphone,uilabel,Iphone,Uilabel,在由分组表视图组成的“我的应用”中,detailTextLabel显示通过日期选择器输入的日期。我使用这些日期从webservice检索数据。我想做的是将UILabels添加到单元格的detailTextLabel中,这样我就可以访问标签的text属性来获取日期并向webservice发送请求。我尝试像这样向detailTextLabel添加标签 cell.detailTextLabel = self.fromDate //fromDate is an instance of UILabel;

在由分组表视图组成的“我的应用”中,detailTextLabel显示通过日期选择器输入的日期。我使用这些日期从webservice检索数据。我想做的是将UILabels添加到单元格的detailTextLabel中,这样我就可以访问标签的text属性来获取日期并向webservice发送请求。我尝试像这样向detailTextLabel添加标签

cell.detailTextLabel = self.fromDate //fromDate is an instance of UILabel;
但它向我展示了错误


如何修复此问题

您应该设置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];