我設法找到解決辦法......它並不像我想
- (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個字符,以便一切都合適。