samedi 29 novembre 2014

UITableView Rows With Dynamic height working in IOS 8 not working in ios 7

I have a tableview in which i need to populate rows with dynamic height.


What I did:


I have a textlabel whose height will be changing dynamically. So when i set the data on my cell i set it like :



-(void)setCommentDataOnCell:(CommentModel*) data
{


CGFloat currentHeigh=_commentTextLabel.frame.size.height,heightDiff;

//Here is the label with dynamic height

_commentTextLabel.text=data.commentText;
[_commentTextLabel sizeToFit];
[self layoutIfNeeded];
heightDiff=_commentTextLabel.frame.size.height-currentHeigh;

// I change the frame of cell here ie, add the height difference in label

[self setFrame:CGRectMake(self.contentView.frame.origin.x, self.contentView.frame.origin.y, self.contentView.frame.size.width, self.contentView.frame.size.height+heightDiff)];
[self layoutIfNeeded];

commentAuthorLabel.text=data.createdUserName;

}


Now i have set the autolayout such that the dynamic cell is aligned to bottom as well as top of the cell's content view


enter image description here


Then i have set following properties for my tableview



commentListTableView.rowHeight=UITableViewAutomaticDimension;
commentListTableView.estimatedRowHeight=44.0f;


Now To What I get:


*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DiscussionDetailViewController tableView:heightForRowAtIndexPath:]: unrecognized selector sent to instance 0x78787760'




I havent implemented this selector heightForRowAt


but i have implemented EstimatedHeight as 75.0f as it was for my prototype cell in my storyboard i also have a headerview for session with height 8.0f




Aucun commentaire:

Enregistrer un commentaire