3

So, I'm in a bit of a bind... According to this post, the orientation of the iPhone/iPad is portrait up to a point after which the "auto-rotate" function inside the controller tells iOS that the orientation has changed. My problem is that it appears as though the tableview cells are loading before I have a chance to detect a change in the orientation. My tableview depends on the orientation of the device, so I can't load it until the orientation is known. Is there something I don't know?

Thanks guys!

Community
  • 1
  • 1
Ptemple
  • 125
  • 6

2 Answers2

1

I believe you are providing support for both the LAndScape and Potrait mode for the application so you should detect the device orientation in the cellForRowAtIndexPath method and create the cell for the current orientation:

if ([UIDevice currentDevice].orientation!=UIDeviceOrientationLandscapeLeft && [UIDevice currentDevice].orientation!=UIDeviceOrientationLandscapeRight) {

 Identifier= @"aCell_portrait"

 }else Identifier= @"DocumentOptionIdentifier_Landscape";
Maulik
  • 19,348
  • 14
  • 82
  • 137
UPT
  • 1,490
  • 9
  • 25
  • Thanks! I eventually came to the conclusion that I had to do this after I tried the previous solution. Somehow it's registering as landscape, but then something changes it to portrait, before changing back to landscape just before the tableview loads. – Ptemple Sep 10 '11 at 04:46
0

When the auto-rotate function is called, you could just run

[tableView reloadData]; 

to reload the table after rotation has occurred.

Jordan Smith
  • 10,310
  • 7
  • 68
  • 114