Customize XMMContentBlocks cell - xamoom/xamoom-ios-sdk GitHub Wiki

There are currently XMMContentBlocks 9 different block types. There is a UITableViewCell for each of these in the SDK. All of them can be customized to fir your design. To do so just follow these steps.

1. Create custom cell

Create a new class that inherits from the XMMContentBlockTableViewCell you want override.

2. Override cell

To setup your custom cell you have to override the configure(forCell block:, tableView:, indexPath:, style:, offline:) function. In this function you can set the block's values to your custom UI elements.

func configure(forCell block: XMMContentBlock!, tableView: UITableView!, indexPath: IndexPath!, style: XMMStyle!, offline: Bool) {
      // customize your cell here.
}

3. Register your cell

To register your cell you have to call register with your new nib.

self.contentBlocks.tableView.register(UINib(nibName: "CustomTableViewCell", bundle: .main), forCellReuseIdentifier: "XMMContentBlockTableViewCell")

4. Additional things for block type 2,3 and 6

If you want to customize XMMContentBlock2TableViewCell, XMMContentBlock3TableViewCell or XMMContentBlock6TableViewCell you have to create a new class and inherit from XMMContentBlocks. In this class you have to override tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) This is needed because XMMContentBlocks handles the click action for these three cells and otherwise it will not trigger your custom cell click action.

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
   // Your logic here
}

For a detailed implementation guide, check the CustomContentBlocks class and the CustomContentBlock6TableViewCell of our Demo App.

Related sources