I am new to IOS, I am trying to make multiple prototype cells in UITableView, but always I am getting same size of rows, no idea why it's behaving like this. I have searched a lot! but no clue, any help will be great for me. Thanks in advance.This is the image for what I am doing and this is what I am getting as output.
here is my code for DataSource methods....
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:
(NSInteger)section
{
return 12;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger count = indexPath.row;
if(count == 0)
{
DetailPostCell *Cell1 = (DetailPostCell *)[tableView
dequeueReusableCellWithIdentifier:@"Cell1"
forIndexPath:indexPath];
return Cell1;
}
else
{
CommentCell *Cell2 = (CommentCell *)[tableView
dequeueReusableCellWithIdentifier:@"Cell2"
forIndexPath:indexPath];
return Cell2;
}
}
you didn't set your layoutconstraint properly.
How?
Remember to add top and bottom constraint at least in one outlet in your cell.just like this.
And In your view controller's viewDidLoad.write these two lines.
self.tableView.estimatedRowHeight = 88.0//your estimated height.don't worry it will take what your custom cell want.:)
self.tableView.rowHeight = UITableViewAutomaticDimension