Raju goud Bingi
Raju goud Bingi

Reputation: 160

Adding a view (image view) in between two UITableViewCells

I have created a UITableView programatically. And i am loading it with data. I want to insert an advertisement Banner (clickable button which is equal to cell's height and width) into this table view after every 4 rows. Is it possible to insert that ? or should i add something to array which i am loading the table view with ?

Thanks in advance.

Upvotes: 1

Views: 829

Answers (2)

slik
slik

Reputation: 5221

As Duncan mentioned you could use cellForRowAtIndexPath and place a custom cell type for every 4th row. You can set two types of custom cells in your tableview by setting the identifier property. Ex. For every 4th row use the "ad" identifier cell.

Upvotes: 2

Duncan C
Duncan C

Reputation: 131436

No, it's not possible. The table view owns its whole area, and renders cells based on it's internal logic.

You could divide your table view into sections and add a custom cell as a section header or footer, or you could make your cellForRowAtIndexPath serve up a custom type of cell for every 4th row that ONLY contains your full-sized button. That should accomplish your goal.

Upvotes: 5

Related Questions