![](/img/trans.png)
[英]How to display the first item of my array in the first section and the remaing in the next section in a tableview?
[英]modifiy first row for each section of my tableview
我會修改每個部分的第一行(修改字體大小,顏色,匹配度)。 我認為是這樣的:
NSInteger sectionRows = [tableView numberOfRowsInSection:[indexPath section]];
if (sectionRows == 0){
cell.textLabel.text = cellDetail;
cell.detailTextLabel.textAlignment = UITextAlignmentCenter;
cell.detailTextLabel.backgroundColor = [UIColor blueColor];
cell.detailTextLabel.font = [UIFont systemFontOfSize:13];
} else {
cell.textLabel.text = cellDetail;
cell.detailTextLabel.text = cellValue;
}
但這並不能解決問題:D請讓我知道是否最好打開另一個主題,或者我們可以在這里繼續。
要獲取indexPath的行號,只需使用indexPath.row
,然后從那里獲取。 因此,將第一行替換為:
NSInteger sectionRows = [indexPath row];
您可以在呈現表格時即時執行此操作。 請參見UITableViewDelegate
的-tableView:willDisplayCell:forRowAtIndexPath:
方法。 這是在繪制單元格之前調用的。 您可以在此處對單元進行自定義。
表格視圖會在使用單元格繪制行之前將該消息發送給其委托,從而允許委托在顯示單元對象之前對其進行自定義。 此方法使代理有機會覆蓋表視圖先前設置的基於狀態的屬性,例如選擇和背景顏色。 委托返回后,表視圖將僅設置alpha和frame屬性,然后僅在為行滑動時為其設置動畫效果。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.