大きなフォントで「この敬虔なオンラインを見る」と言うUITableViewセルを作成しようとしています。私が抱えている問題は、セル内のテキストがラッピングされていないため、フレーズの一部で終わることです。iPhone UITableViewCellでテキストを折り返し
このため、私が持っているコードは次のとおりです。
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Get cell
static NSString *CellIdentifier = @"CellA";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
// Display
cell.textLabel.textColor = [UIColor blackColor];
cell.textLabel.font = [UIFont systemFontOfSize:15];
if (item) {
// Item Info
NSString *itemTitle = item.title ? [item.title stringByConvertingHTMLToPlainText] : @"[No Title]";
// Display
switch (indexPath.section) {
case SectionHeader: {
// Header
switch (indexPath.row) {
case SectionHeaderTitle:
cell.textLabel.font = [UIFont boldSystemFontOfSize:15];
cell.textLabel.text = itemTitle;
break;
case SectionHeaderDate:
cell.textLabel.text = dateString ? dateString : @"[No Date]";
break;
case SectionHeaderURL:
cell.textLabel.text = @"View this devotional in full website";
cell.textLabel.textColor = [UIColor blackColor];
cell.textLabel.font = [UIFont systemFontOfSize:36];
cell.imageView.image = [UIImage imageNamed:@"Safari.png"];
cell.textLabel.numberOfLines = 0; // Multiline
break;
}
break;
}
case SectionDetail: {
// Summary
cell.textLabel.text = summaryString;
cell.textLabel.numberOfLines = 0; // Multiline
break;
}
}
}
return cell;
}
次の行は前に働いていたが、ここで働いていないようです。
cell.textLabel.numberOfLines = 0; // Multiline
誰かが私のテキストをラップする方法を見せてもらえますか?
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
(コンパイルされていないが、あなたのアイデアを得る):ゼロにnumberOfLines
の設定に加えて
それが動作need-だろうが、今のテキストは、実際 –
を遮断します。ただし、実際には、このメソッドを実装するときは、すべての行の高さとこの特別な行の特別な高さを指定する必要があります。 –
ただし、各行の高さを計算する必要はありません。デフォルトの高さを使用する場合は、単に 'tableview.rowHeight'を返します。 – thomashw