iOS中使用UItableviewcell实现团购和微博界面的示例

2020-01-14 18:26:55于海丽

            [arrayM addObject:tg];
        }
        _tg=[arrayM mutableCopy];
    }
    return _tg;
}


#pragma mark- xib创建cell数据处理

#pragma mark 多少组
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

#pragma mark多少行
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.tg.count;
}

#pragma mark设置每组每行
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //1.创建cell
    YYtgcell *cell=[YYtgcell tgcellWithTableView:tableView];
   
    //2.获取当前行的模型,设置cell的数据
    YYtgModel *tg=self.tg[indexPath.row];
    cell.yytg=tg;
    
    //3.返回cell
    return cell;
}

#pragma mark- 隐藏状态栏
-(BOOL)prefersStatusBarHidden
{
    return YES;
}

@end


四、推荐调整的项目文件结构

 

iOS中使用UItableviewcell实现团购和微博界面的示例

这是调整后的文件结构,完整的MVC架构。

注意:注意文件的命名规范。

提示技巧:批量改名,操作如下:

iOS中使用UItableviewcell实现团购和微博界面的示例

修改为想要的名称: