0
我有一個表格視圖,每個部分有4個部分和1個行。是否有辦法讓第一部分的行比其他行更大?表視圖部分高度
我有一個表格視圖,每個部分有4個部分和1個行。是否有辦法讓第一部分的行比其他行更大?表視圖部分高度
是的,這是可能的。您可以在返回之前更改單元格的框架
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
因此它更大。只需添加類似
UITableViewCell * cell = ...
// ...
if(indexPath.section == 0 && indexPath.row == 0){
// change the frame of the cell
}
// ...
return cell;
實現以下方法(從UITableViewDelegate
實施)
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 0)
{
return 100; // the desired height
}
else
{
return 44; // or whatever your default cell height is
}
}
編輯:誤解你的問題。按照沃克斯特的建議。
我使用awakeformnib,在那裏我設置高度如何獲得該方法中的部分?謝謝 – Alfonso
我用這個方法heightForRowAtIndexPath感謝您的幫助 – Alfonso
我很高興我可以幫助:) – Warkst