Objective c 自动换行是否需要自定义tableViewCell?如果没有,这是如何做到的?

Objective c 自动换行是否需要自定义tableViewCell?如果没有,这是如何做到的?,objective-c,uitableview,Objective C,Uitableview,不,这不是必需的,您可以通过将numberOfLines从textLabel设置为0来轻松进行换行,它将自动对内容进行换行 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"

不,这不是必需的,您可以通过将
numberOfLines
textLabel
设置为0来轻松进行换行,它将自动对内容进行换行

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

       UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MCell" forIndexPath:indexPath];

switch (indexPath.row) {
    case 0:
        cell.textLabel.text = @"My Policies";
        cell.textLabel.textColor = [UIColor redColor];
        ***cell.textLabel.numberOfLines = 0;***
        break;
    case 1:
        cell.textLabel.text = @"Payment Info";
        cell.textLabel.textColor = [UIColor redColor];

        break;
    case 2:
        cell.textLabel.text = @"Policy Notes";
        cell.textLabel.textColor = [UIColor redColor];

        break;
    case 3:
        cell.textLabel.text = @"Events";
        cell.textLabel.textColor = [UIColor redColor];

        break;
    default:
        cell.textLabel.text = @"Docs";
        cell.textLabel.textColor = [UIColor redColor];

        break;
}


      return cell;
}

请你详细解释一下好吗?不要用简单的代码,而是提供一些你需要的描述
cell.textLabel.numberOfLines = 0;