How to make a alternate cel开发者_JAVA技巧l with a different height?
I need height for cell1 is 60 and cell2 is 30....
how can i do this?
Thanks in advance.
you can set the height of cell from the delegate method of table view
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row==0)
{
return 60;
}
else if(indexPath.row==1)
{
return 20;
}
}
and so on....
Happy coding....
Use the modulus operator and you dont need an if case for every row index :)
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row % 2 == 0)
{
return 60;
}
else
{
return 30;
}
}
精彩评论