Trong tableView:cellForRowAtIndexPath:
bạn có thể đặt một vài thuộc tính trên textLabel (hoặc descriptionLabel, tùy thuộc vào kiểu ô bạn đang sử dụng) để thực hiện việc này. Đặt font
để thay đổi font chữ, linkBreakMode
để làm cho nó word-wrap, và numberOfLines
để thiết lập có bao nhiêu dòng max (sau đó trỏ nó truncates. Bạn có thể đặt đó để 0 cho không max.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell* aCell = [tableView dequeueReusableCellWithIdentifier:kMyCellID];
if(aCell == nil) {
aCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kMyCellID] autorelease];
aCell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:10.0];
aCell.textLabel.lineBreakMode = NSLineBreakByWordWrapping; // Pre-iOS6 use UILineBreakModeWordWrap
aCell.textLabel.numberOfLines = 2; // 0 means no max.
}
// ... Your other cell setup stuff here
return aCell;
}
này không được chấp nhận trong iOS6. Làm thế nào để bạn có thể làm cho nó trong iOS6? – Napolux
Theo tôi biết điều duy nhất không được chấp nhận trong iOS6 là 'UILineBreakModeWordWrap'.' NSLineBreakByWordWrapping' là tương đương iOS6. – zpasternack