Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

macprogrammer80

macrumors newbie
Original poster
Apr 22, 2009
15
0
I have an app which I have set to support landscape (which works fine) but when I turn the device on its side, the UITableView does not resize itself. What is the easiest way of
a) Checking for the UIOrientation
b) Adjusting the table accordingly

What I was thinking was a simple if-else statement when laying out the table view, but it only ever runs the loop once, so when the device is rotated, it doesn't change the contents.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
You need to set the autoResize flag of the tableview to flexible height and flexible width. Then it will resize whenever its parent view resizes.
 

macprogrammer80

macrumors newbie
Original poster
Apr 22, 2009
15
0
You need to set the autoResize flag of the tableview to flexible height and flexible width. Then it will resize whenever its parent view resizes.

Thanks, here's the code I have:
Code:
cellView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

The issue I have though is that the content stretches pretty much beyond readability. What I was hoping is that I can have an if-else statement comparing the current interface rotation, and re-drawing the table view info.

Is there any way to do this, or have I done the above code wrong?
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
There are a couple issues. Is the table view resizing correctly? Is the content of the table view cells being resized correctly?

You asked about the table resizing correctly. My answer was regarding that issue.

If the table itself is resizing correctly you need to also design your cells so they resize. You need to set the autoResizingMask correctly for the content of your cells also. In some cases the content is too complicated for that and you need to implement layoutSubviews in your UITableViewCell subclass.

If this isn't enough info for you then show how you build your cells.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.