我有一個tableview
但沒有任何單元顯示更長的文本。更奇怪的是,它似乎並沒有成爲一個定價。有些單元在被切斷之前顯示的文本比其他單元更多。 NSLog()
確認字符串設置正確。UITableViewCell不顯示全文
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//code for getting string removed for readability
// Identifier for retrieving reusable cells.
static NSString *cellIdentifier = @"MyCellIdentifier";
// Attempt to request the reusable cell.
cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
// No cell available - create one.
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
// format it
cell.textLabel.numberOfLines = 0;
cell.textLabel.font = [UIFont systemFontOfSize:12.0];
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
}
// Set the text of the cell to the row index.
cell.textLabel.text = fulltext;
return cell;
}
我的印象是在0
的numberOfLines
功能會處理,但所有的細胞都在2線,沒有更多的。我如何讓它們根據需要調整到儘可能多的行數?謝謝。
'[NSString stringWithFormat:@「%@」,fulltext'是不必要的,只需使用'fulltext'即可。 – zaph
是的,我在做實驗時就這麼做了,現在剛剛抓住它,已經改變了它。我也添加了cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;但它仍然沒有包裝。 –
您可能需要使單元高度更大,並使UILabel高度更大。 – zaph