Thursday 15 September 2011

uitableview - Change height of UITextView in cellForRowAtIndexPath -


I am trying to change the height of a UITextView that is in a custom created cell for my table view.

'Overview Cell' is an identifier for this custom cell in a Nibbet and the UITextview 'Post Indent' has been dragged into the nib.

Unfortunately, not enough height is changing, only when I change the height of the scroll. The cells that are visible without scrolling are only the default height of the nibb.

When I try to change the height of the 'post image' then the problem is the same.

This is my code:

  - (UITableViewCell *) TableView: (UITableView *) Table View CellForOutPath: (NSIndexPath *) Index Path {Fixed NSString * CellIdentifier = @ " Observes "; Observation cell * cell = [self.tableView dequeueReusableCellWithIdentifier: cellindex for indexPath: indexpath]; Post * Post = [self.posts objectAtIndex: [index line]]; If (! Cell) {NSArray * topLevelObjects = [[NSBundle mainBundle] loadNibNamed: @ "overview" owner: zero option: zero]; (Id currentObject in topLevelObjects) {if ([currentObject isKindOfClass: [OverviewCell class]]) {cell = (observation *) currentObject; break; }}} [[Cell Post Image] Set Image: [UIImage imageWithData: post.image]]; [[Cell postetal] set test: post title]; [[Cell posttranslation] set text: post.interro]; // Change the size of the intro text so that the text fits. Cgtt frame = cell Postmusic.fr; Frame.edame.height = 20; //cell.postIntro.contentSize.height; [Cellpostintro setframe: frame]; NSLog ([NSString stringWithFormat: @ "the height of the text is set to% F on the% i indexpoint; index.path.row, cell.postImage.frame.size.height]); Return cell; }   

Any other suggestions in my code are welcome ...

I am finally working on it by changing the UITextview barrier in the code.

I have created and IBOutlet that is linked to the UITActewviewview barrier.

  IBotlet NSLayt Consultant * Post Contact High Consultant;   

Then I set the height of the obligation to the specified height for the cell ( contentSize ).

  Self PostContentHeightConstraint.constant = self.postContent.contentSize.height;   

After setting the new height to the barrier, call the Layout IIFNeeded function on UITextView

  [self.postContent layoutIfNeeded];    

No comments:

Post a Comment