UITableView NSIndexPath屬性講解

NSIndexPath 是一個對象,它用來表示一個樹形的記錄地址。

提到UITableView,就必須的說一說NSIndexPath。UITableView聲明瞭一個NSIndexPath的類別,主要用 來標識當前cell的在tableView中的位置,該類別有section和row兩個屬性,前者標識當前cell處於第幾個section中,後者代 表在該section中的第幾行。

  UITableView只能有一列數據(cell),且只支持縱向滑動,當創建好的tablView第一次顯示的時候,我們需要調用其reloadData方法,強制刷新一次,從而使tableView的數據更新到最新狀態。

NSIndexPath的創建

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];

-(void)cellImageDidLoad:(NSIndexPath *)indexPath image:(UIImage *)image
{
    UITableViewCell *cell = [wqTablecellForRowAtIndexPath:indexPath];
    cell.imageView.image = image;
}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章