Faced such a problem. with long text, the program should otomatically spend the night on the line below. It seems that everything is written correctly, and the speed of the "0" is different, but it does not do everything that is necessary. Help pliz!
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath int elementNumber = [indexPath section]; static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier"; UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier]; if(cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier] autorelease]; } SMXMLElement *elem = [[self.globalArray objectAtIndex:indexPath.section] objectAtIndex:0]; NSString* tmpStr = [elem attributeNamed:@"text"]; NSString* tmpStrT = [elem attributeNamed:@"author"]; NSArray *children = [NSArray arrayWithObjects:tmpStr, tmpStrT, nil]; cell.textLabel.text = [children objectAtIndex:0]; cell.detailTextLabel.text = [children objectAtIndex:1]; return cell; } - (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath: (NSIndexPath *) indexPath { int elementNumber = [indexPath section]; SMXMLElement *elem=[[self.globalArray objectAtIndex:indexPath.section] objectAtIndex:0]; NSString *str = [elem attributeNamed:@"text"]; UILabel *longi = [[UILabel alloc] initWithFrame: CGRectMake(0, 0, 280, 0)]; longi.numberOfLines = 0; longi.text = str; [longi sizeToFit]; float i = longi.frame.size.height; [longi release]; return i; }