我设法找到解决办法......它并不像我想
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
Favorites *favorite = [fetchedResultsController objectAtIndexPath:indexPath];
cell.textLabel.text = favorite.name;
NSLog(@"%d",[favorite.name length]);
NSLog(@"%@",favorite.name);
if ([favorite.name length] <= 34) {
cell.textLabel.numberOfLines = 1;
NSLog(@"no. of lines = 1");
}else{
cell.textLabel.numberOfLines = 2;
NSLog(@"no. of lines = 2");
}
cell.detailTextLabel.text = favorite.subTopic;}
的configureCell
方法被称为在我- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
基本上我检查数量为复杂字符串中的字符。我发现幻数是34个字符,以便一切都合适。