TableViewCell注册的小问题

注册cell的方法   

- (void)registerClass:(nullable Class)cellClass forCellReuseIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(6_0);

当谢了这个注册Cell的方法时候

这样你在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath这个方法里,你就可以省下这些代码:


    static NSString *CellIdentifier = @"Cell";
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
      //设置你的cell

而只需要



    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

这样也可以注册Cell 

posted @ 2015-12-25 11:44  guySang  阅读(200)  评论(0)    收藏  举报