2

Trying to support Landscape orientation, following is the drawing code. NOTE: aCell is object of UIControl class:-

- (void)layoutCells 
{
  for ( UIView *aCell in _cells ){
    if ( [aCell superview] != self )
        [self addSubview:aCell];

    int height = [[UIScreen mainScreen] bounds].size.height;
    if (height >= 568)// iPHone  5
    {
        CGRect cellFrame = aCell.frame;
        cellFrame.size.height = 520;
        [aCell setFrame:cellFrame];

        [aCell         setCenter:_spinCenter];
        [[aCell layer] setAnchorPoint:CGPointMake( 0.5, (_spinCenter.y/(self.frame.size.height+70)))];
    }

    else{
            [aCell         setCenter:_spinCenter];
            CGRect frame = CGRectMake(60.f, 424.f, 200.f, 460);
            [[aCell layer] setAnchorPoint:CGPointMake( 0.5, _spinCenter.y/frame.size.height )];
    }
    // Clockifying happens with "selectCellAtIndex:animated:".
  }
}
Paresh Navadiya
  • 38,095
  • 11
  • 81
  • 132
Zubair
  • 5,833
  • 3
  • 27
  • 49
  • Here you go try this link. It explains how to [how to change landscape to portrait and vice versa on iPhone ][1] [1]: http://stackoverflow.com/a/13356988/1825557 – James Leshko May 21 '13 at 18:16

1 Answers1

1

All you need to do is to support the rotation in the view controller that contains the view to which you add the cells (self in your example).

In addition, notice that in landscape (if your view supports rotation) window height is equal (if in full screen) to view width.
Therefore, you will have to reconsider the next line:

cellFrame.size.height = 520;

In case of lanscape the width should be altered instead of the height...

Michael Kessler
  • 14,245
  • 13
  • 50
  • 64
  • What exactly doesn't work? The containing view doesn't rotate or the inner views (the cells) don't rotate? – Michael Kessler May 22 '13 at 04:46
  • The Containing is even not rotating – Zubair May 22 '13 at 10:46
  • "The Containing is even not rotating" - it means that the problem is not in the code that you have shared here. The problem is in rotating the view of the current view controller. There are plenty of questions about it (with not less answers) here in SO. Few samples: [http://stackoverflow.com/questions/12728390/portrait-and-landscape-mode-in-ios6/13881884#13881884], [http://stackoverflow.com/questions/13744701/landscape-mode-in-ios6-in-middle-of-the-app] etc... – Michael Kessler May 22 '13 at 12:59