ios知识

iOS Tableview dequeueReusableCel

2016-06-20  本文已影响2640人  阳仔dynamics

网上版本

带indexPath的方法总是返回一个cell(也就是说不可能为空),另一个方法是有可能为nil的;即:在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath方法中可以省略以下代码:

if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

自测版本

上一篇 下一篇

猜你喜欢

热点阅读