支持横向环境的UIVIEWS:

时间:2013-05-08 12:48:11

标签: iphone ios5

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

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

1 个答案:

答案 0 :(得分:1)

您需要做的就是支持包含添加单元格的视图的视图控制器中的旋转(在您的示例中为self)。

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

cellFrame.size.height = 520;

如果是lanscape,则应改变宽度而不是高度...