UITableView的cell兩種注冊方法:
[_tabV registerClass:[testTableViewCell class] forCellReuseIdentifier:@"cellId"];
testTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellId" forIndexPath:indexPath];
testTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
if (!cell) { cell = [[testTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cellId"]; }
系統(tǒng)推薦使用第2中方法。
創(chuàng)建一次的視圖寫在花括號里面矩动,第1種方法復用的時候需要判斷只需創(chuàng)建一次的視圖在沒在贩耐,在的話需要刪除重建葛虐,不然會疊加在一塊兒