This is an extension of a tutorial I wrote for RayWenderlich.com on how to create a swipeable UITableViewCell for iOS 7 without driving yourself completley insane with UIScrollViews. (Drive yourself insane with constraints instead!)
The crux of the problem is that while adding a delete button is super-easy, adding a delete button AND another button is a total nightmare because of the way the cells are constructed.
I've refactored the code that was included in the tutorial, which is is more meant as an exercise in helping n00bs dive into figuring out how Apple's code works under the hood, into this library, which I'm hoping will be helpful for anyone dealing with this in production code.
myContentView
public so the cell could be subclassed and recycled more easily.accessoryType
, that view will automatically be removed and replaced when the cell is opened and closed (respectively). myContentView
along with an accessory, remember to set that same color as the background color for the cell itself, or the accessory's going to have a different background color..xib
, you have to add a myContentView
view, and hook up the NSLayoutConstraint
outlets to the left and right constraints. See the sample project for an example of how to set this up..xib
, make sure you're sending any calls to the superclass during setup which need myContentView
to not be nil
through awakeFromNib
instead of initWithCoder:
, since the IBOutlet
won't be hooked up until awakeFromNib
has fired. All photos Copyright Ellen Shapiro. If you want to see more photos of my jerkface cat, Chaplin, follow me on Instagram.