저는 현재 Json을 통해 Twitter 피드를 받고 있으며, tweet의 길이를 알기 전에 heightForRowAtIndexPath가 호출되고 있습니다. heightForRowAtIndexPath가로드 될 때 fullTweet.length는 항상 0입니다. 이 여분의 빈 공간을 낭비하지 않도록이 http://gyazo.com/632d09685268e1737d3c58bf1718cbff.png 같은 셀의 크기를 조정하려고합니다.heightForRowAtIndexPath가 너무 일찍 호출되고 있습니다.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if(fullTweet.length >= 50) {
return 50.0f;
} else
return 92.0f;
}
내 방법은
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"TweetCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSDictionary *tweet = [tweets objectAtIndex:indexPath.row];
NSString *text = [tweet objectForKey:@"text"];
cell.textLabel.text = text;
fullTweet = text;
NSLog(@"%i", fullTweet.length);
cell.textLabel.numberOfLines = 3;
return cell;
}
모든 아이디어를 어떻게 작동 하는가?