Mixing Dynamic And Static Cells In Tableview

Work on my new app continues. As I said in previous post, it’s main functionality focuses on displaying a table view. Table view with a lot of items, divided into sections, based on their creation date. Those items are contacts from address book and so far it looks something like this:

Contacts Timeline tableview

Contacts Timeline tableview

App ratings can have positive effect on its success so I wanted to implement some way to gently ask users for rating of my app and I found this great article from Circa app team. And you might noticed in above picture I tried to do similar thing – integrating rating request between tableview items.

Rating request is static cell and contacts are dynamic cells. So how to mix those together?

First it’s good to create custom class for our static cell with having checked Also create XIB file option:

RateTableViewCellThis way we have more control over it and we can set layout in Interface Builder.

Now there’s only few things left. In tableView:cellForRowAtIndexPath: function, where are defined dynamic cells, I’ve added code, to show static cell as specific row in specific section:

Since we’re adding new cell, we have to state that there will be one more for that specific section in tableView:numberOfRowsInSection:

Finally, my static cell has bigger height than the other cells, so this also has to be defined:

I like it, definitely better way to ask for reviews than annoying pop-ups. See you next time.

Update: Here’s the sample project – Table View With Static And Dynamic Cells