I've tried every thing I can think of, and nothing is working.
Similar to the effect in iOS 7's Mail.app, I want to be able to slide the cells of my table view right and left. I want to be able to do this in a Storyboard and Auto Layout, as most of my app is done with those. I understand scroll views with Storyboards calculate their contentSize by the constraints of their subviews.
With that, I've predominantly tried two strategies. The first, just have a label in the scrollview that I can slide right or left. I set it to be stuck to the top of the scroll view and the bottom, but 300pts on either side of the label to allow the scroll view to calculate its contentSize. This pushes the label enormously to the right so I can't see it when the table loads.
Option two, the preferable one, is to put a UIView in the scroll view, and then put the label and whatnot within that so they can be all positioned as a group with their UIView parent. I've tried simply setting the UIView here, setting it to be stuck to the top and bottom of the scroll view, the width is set to 320, while the left and right side are 320 away from the edges.
This complains that there's no height constraint, but I told it to stick to the top and bottom of the scroll view. How does that not count? If the cell size grows, the scroll view is set to grow with it, and as a result I want the inner view to grow in height as well. It also complains of the position horizontally for some reason.
Here's an example project with all the constraints mentioned.
What on earth is going on? Is this an impossible task?
UITableView manages the basic appearance of the table, but your app provides the cells ( UITableViewCell objects) that display the actual content. The standard cell configurations display a simple combination of text and images, but you can define custom cells that display any content you want.
A prototype cell acts a template for your cell's appearance. It includes the views you want to display and their arrangement within the content area of the cell. At runtime, the table's data source object creates actual cells from the prototypes and configures them with your app's data.
I would add a scroll view to each cell's contentView.
I would set the scroll view width to one-third of the with of the cell, set paging enabled and not to clip its subviews.
Then add a "real" content view inside with the width of the cell that will hide the underlying buttons.
Finally you have to set programmatically the correct contentSize
(width of the cell) and initial contentOffset
(one-third of the width).
You can also play with the scroll view contentInsets
to further adjust it.
Sample Nib code here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With