2010-07-15 36 views
0

在我的應用程序中包含一個分組的tableView,detailTextLabel顯示通過日期選擇器輸入的日期。我使用這個日期從webservice檢索數據。我想要做的是將UILabels添加到單元格的detailTextLabel,以便我可以訪問標籤的文本屬性以獲取日期並將請求發送到webservice。我嘗試添加標籤的detailTextLabel這樣將UILabel添加到UITableViewCell的detailTextLabel

cell.detailTextLabel = self.fromDate //fromDate is an instance of UILabel; 

但它顯示我的錯誤...

我怎樣才能解決這個

回答

1

您應該設置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]; 
相關問題