How to make a alternate cell 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;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.