Note that there are some explanatory texts on larger screens.

plurals
  1. POChange height of UITextView in cellForRowAtIndexPath
    primarykey
    data
    text
    <p>I'm trying to change the height of an UITextView which I have in a custom made Cell for my tableView.</p> <p>The 'OverviewCell' is an identifier of this custom cell in a nib and also the UITextView 'postIntro' is dragged into the nib.</p> <p>Sadly enough the height is not changing, only after i scrolled the height is changed. The cells which are visible without scrolling are just the default height from the nib.</p> <p>When i try to change the height of the 'postImage' the same problem happens.</p> <p>This is my code:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"OverviewCell"; OverviewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; Post *post = [self.posts objectAtIndex:[indexPath row]]; if(!cell) { NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"OverviewCell" owner:nil options:nil]; for(id currentObject in topLevelObjects) { if([currentObject isKindOfClass:[OverviewCell class]]) { cell = (OverviewCell *)currentObject; break; } } } [[cell postImage] setImage:[UIImage imageWithData:post.image]]; [[cell postTitle] setText:post.title]; [[cell postIntro] setText:post.intro]; // Resize the intro textview so the text fits in. CGRect frame = cell.postImage.frame; frame.size.height = 20; //cell.postIntro.contentSize.height; [cell.postIntro setFrame:frame]; NSLog([NSString stringWithFormat:@"Height of textView on indexpath %i is set to %f", indexPath.row ,cell.postImage.frame.size.height]); return cell; } </code></pre> <p>Any other suggestions to my code is welcome...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload