views:

1938

answers:

3

UiTableView does not provide Horizontal Scrolling in landscape mode.

My UiTableView is not full screen (So I cannot just use it horizontal mode while rotating my content, which are pictures)

I found that to rotate my UiTableView using Transforms.. I have to position it in Interface Builder in some weird position so that when rotated, it just looks right.....

Has anyone done this without messing around with Interface Builder ? Same code?

A: 

See the Autoresizing Behaviors section on the Windows and Views conceptual guide on Apple's site. That explains how to achieve automatic rotation from portrait to landscape and back again without using Interface Builder and without having to deal with manually implementing complex transforms.

As for rotating your custom content and disabling scrolling, see shouldAutorotateToInterfaceOrientation:interfaceOrientation, willRotateToInterfaceOrientation:duration:, and didRotateFromInterfaceOrientation: in UIViewController. You can implement these methods to intercept rotation events, check which orientation you are moving to, and take care of your custom drawing and properties setting stuff there.

Edit

In response to your comment, I found this bit from the Table View Programming Guide from Apple:

UITableView inherits from UIScrollView, which defines scrolling behavior for views with content larger than the size of the window. UITableView redefines the scrolling behavior to allow vertical scrolling only.

Perhaps Apple has deemed horizontal scrolling of table views to be against their human interface guidelines. I wonder if you could re-re-define the scrolling behavior if you subclassed UITableView, but that would probably be a ton of trial and error work. If you are actually able to accomplish this, I'm sure many people here would be interested in how you did it. I searched around for a while trying to find other people's solutions, but I couldn't find anything out there.

Then again, Apple may not allow your app into the app store if you did this, assuming it really does break the HIG.

Marc W
Thanks for your answer but as mentioned, UiTableView does not provide Horizontal SCrolling in landscape mode. So if I used autorotation, it will only scrolling up and down and NOT LEFT <-> RIGHT.
A: 

?? I also want table view show in horizontal scrolling mode but only vertical scrolling mode , seem sdk doesn't support it ??? will it be provides in next version ?

A: 

You can achieve what you are looking for by doing the following:

  1. Create a UITableView and attach it to a UIViewController, either by code or via IB (do not use a UITableViewController)
  2. Apply a 90 degrees counterclockwise transformation to your table.
  3. In your tableView:cellForRowAtIndexPath: method, apply a 90 degrees clockwise transformation to your cells before returning them.

Boum! You've got now a horizontal-scrolling table with vertical cells. You might have to correct the width and height of your cells and your table to make everything look right, but I suppose this might help you.

Another tip: you can control the center point of the rotation using the table's layer. anchorPoint property (it's a CGPoint). If you set it elsewhere than the the center of the view bounds, the rotation effects (and any other effects) will use that point as reference.

Adrian Kosmaczewski