This is the method that I use:
1) Implement you own subclass of UITableView and override its initWithCoder:
method as shown below:
- (id)initWithCoder:(NSCoder *)aDecoder
{
assert([aDecoder isKindOfClass:[NSCoder class]]);
self = [super initWithCoder:aDecoder];
if (self) {
const CGFloat k90DegreesCounterClockwiseAngle = (CGFloat) -(90 * M_PI / 180.0);
CGRect frame = self.frame;
self.transform = CGAffineTransformRotate(CGAffineTransformIdentity, k90DegreesCounterClockwiseAngle);
self.frame = frame;
}
assert(self);
return self;
}
2) Create your own UITableViewCell class and override initWithCoder:
again:
- (id)initWithCoder:(NSCoder *)aDecoder
{
assert([aDecoder isKindOfClass:[NSCoder class]]);
self = [super initWithCoder:aDecoder];
if (self) {
const CGFloat k90DegreesClockwiseAngle = (CGFloat) (90 * M_PI / 180.0);
self.transform = CGAffineTransformRotate(CGAffineTransformIdentity, k90DegreesClockwiseAngle);
}
assert(self);
return self;
}
3) Now you can create a UITableView element in IB and set its class to be "MyHorizontalTableView" in the identity inspector.
4) Create your UITableViewCell element in IB and set its class to be "MyHorizontalTableViewCell" in the identity inspector.
And that's it.
This would work by overriding other initializers too in case you prefer not to use IB to instantiate your table view or cell.
A sample project that I built around this concept can be found in GitHub.