我有这段代码,用于将文本放置在 UITableView 单元格中。它给了我一个错误。
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
UIFont *cellFont = [UIFont fontWithName:@"Helvetica" size:17];
CGSize constraintSize = CGSizeMake(self.itemList.frame.size.width, MAXFLOAT);
CGSize labelSize = [[items_array objectAtIndex:indexPath.row] sizeWithFont:cellFont constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];
return labelSize.height + 30;
}
错误发生在这一行:
CGSize labelSize = [[items_array objectAtIndex:indexPath.row] sizeWithFont:cellFont constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];
这是错误:
uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary sizeWithFont:constrainedToSize:lineBreakMode:]: unrecognized selector sent to instance 0x834b020'