UitableView单元格之间的广告,该单元格使用核心数据与nsfetchedresultscontroller
(我已经推荐此stackoverflow Post ,但是我找不到我正在寻找的东西对于)
我需要在uitableView
的单元格之间显示广告。
上图仅用于表示目的,并且不显示我正在使用的应用程序使用的实际设计/数据。
uitaiteView 来自
核心数据
通过nsfetchedResultScontroller
使用fetchController.Object.object(at:indexpath)
,而AD单元格完全来自不同的数据源。
- 由于需要在实际的表视图单元格之间显示广告,因此它将
indexpath
nsfetchedResultScontroller
弄乱,以从core core data 提取请求。
- 此外,用户可以选择从
uiateview
中删除任何实际单元格(非AD单元格),该可以在转移中更改单元格的indexpath
。 - 单元格中可能显示的广告数量可变,现在假定它是常数
c
。
请让我知道是否有一种有效处理所有这些边缘情况的方法,最好不要更改indexpath
fetchcontroller.object中使用的对象(at:indexpath)
。
(I have already referred this StackOverflow post, however did not find what I was looking for)
I have a requirement to show ads in between cells of a UITableView
.
The image above is used only for representational purposes, and does not show the actual design/data used by the app I am working with.
The normal cells of the UITableView
come from a Core Data
fetch request via NSFetchedResultsController
using fetchController.object(at: indexPath)
, whereas the ad cells come from a different data source altogether.
- Since the ads need to be shown in between the actual table view cells, it messes up the
indexPath
used byNSFetchedResultsController
to retrieve the object fromCore Data
fetch request. - Also the user has the option to delete any of the actual cells (non-ad cells) from the
UITableView
, which can in-turn change theindexPath
of the cells. - There can be variable number of ads shown in the cells, for now assume it to be a constant
c
.
Please let me know if there is a way to handle all these edge cases efficiently, preferably without changing the indexPath
object used in fetchController.object(at: indexPath)
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在表查看单元格类中添加标志,说明是否显示AD:
使用以上,剩下的就是存储一个随机生成的索引您想显示广告的位置,并相应地更新单元格:
You can add a flag to your table view cell class, telling if to show an ad or not:
With the above in place, what's left is to store an array of randomly generated indices where you want to show the ads, and update the cell accordingly: