我需要在表格视图中每五个新闻单元格后添加一个仅包含图像的广告单元格.
如果我要为广告单元格添加第二部分,则会在所有新闻单元格后显示广告单元格.如果我要添加广告单元格indexPath.row == 4,我的第五个新闻单元格将不会出现因为cell.details = news[indexPath.row].
有什么建议我该怎么办?谢谢.
在UITableViewDataSource的方法cellForRowAtIndexPath中做下一步:
if (indexPath.row % 5 == 0) {
// configure ad cell
} else {
// configure usual cell with news[indexPath.row - (indexPath.row / 5)]
}
Run Code Online (Sandbox Code Playgroud)