We are using Monotouch to develop an application that is specific to the iPad, but I suspect the same question applies to standard xcode/cocoa applications.
Our issue is that we have UITableViews that must scroll both horiztonally and vertically (please do not suggest that we change the design as that is not a viable option).
We can easily get the UITableView to behave this way by setting the ContentSize to the appropriate size (we set the width to the width of the contained data and the height to the UITableView’s height).
However, there is an unpleasant side-effect to this: the header view and the lines separating each of the rows are is clipped to size of the frame when scrolled horizontally. Interestingly, content continues to be shown, although I suspect that this is a function of displaying our data through subviews added to the cell’s contentview.
I have tried just about every combination of settings in the UITableView (clipping, setting bounds, opacity, etc) all to no avail.
We have verified that this will work correctly if we embed the UITableView in a UIScrollView, but we would prefer not to take this approach due to the inability to reuse cells (there could be a lot of data presented by these tableviews) and other reasons (apple says not to).
Can anyone point us in the right direction? I don’t understand why this is so difficult.
I don’t guarantee that the following will work, but you can try the following.
To fix the header view, you will need to add your header content to a dummy containerView and then use this dummy containerView as the table headerView.
Now, you should set
containerView.clipsToBounds = FALSEand the frame for your header content to the desired width (if you know it).Also, make sure that the header content will have no autoresizing masks set. We don’t want it to change its frame no matter what happens to the containerView.
The idea behind this is that the tableView will resize the frame of your containerView, but will leave your header content frames untouched. And by setting the clipping to FALSE, you should get your content to spill outside of the containerView… voila… hopefully
To fix the separator lines, my only solution I can think of is to make your own separator lines in the cells. You can then have full control over its size.
I’ve dome something similar with the header view, and I managed to get the content to spill.