2013-05-08 33 views
2

试图支持Landscape orientation,以下是绘图代码。注:aCell是UIControl类的对象: -支持横向的UIVIEWS:

- (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:". 
    } 
} 
+0

在这里,你去试试这个链接。它说明了如何 [如何改变横向到纵向,反之亦然iPhone] [1] [1]:http://stackoverflow.com/a/13356988/1825557 – 2013-05-21 18:16:49

回答

1

所有你需要做的是支持包含向其中添加的细胞(在你的例子个体经营)视图中的视图控制器的旋转。

另外,请注意,在横向(如果您的视图支持旋转),窗口高度等于(如果在全屏幕中)查看宽度。
因此,您将不得不重新考虑下一行:

cellFrame.size.height = 520; 

在lanscape的情况下,宽度应被改变,而不是高度...

+0

我已经试过这个,但不知其不为我工作 – Zubair 2013-05-21 17:21:41

+0

什么不工作?包含视图不旋转或内部视图(单元格)不旋转? – 2013-05-22 04:46:13

+0

包含甚至不旋转 – Zubair 2013-05-22 10:46:20

相关问题