2011-01-21 33 views
0

我的iPhone应用程序有两个内容框。当用户切换的手机包装盒的方向改变这样的位置:iPhone方向 - 两个盒子

肖像

|---------| 
| BUTTON1 | 
| BUTTON2 | 
|---------| 
|   | 
| BUTTON3 | 
| BUTTON4 | 
|   | 
|---------| 

景观

|---------|---------------| 
| BUTTON1 | BUTTON3 | 
| BUTTON2 | BUTTON4 | 
|---------|---------------| 

什么是正确的方式去?两个XIB,其他技巧?我应该在代码中手动调整元素大小吗?

回答

2

使用这样的事情:

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ 
if(toInterfaceOrientation == UIInterfaceOrientationPortrait){ 
    button.frame = CGRectMake(20,20,125,125); 
    }else{ 
    button.frame = CGRectMake(20,20,125,125); 
    } 
} 

当然,你必须使用你自己的尺寸在CGRectMake框中,但除此之外,我希望这有助于。

+0

好,所以你建议我用代码手动调整它们的大小? – xpepermint 2011-01-21 21:44:13

0

您可以在视图控制器使用此方法:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration; 

要调整箱“/视图”框架。我相信他们会自动生成动画。

查阅文档以获取更多信息。

+0

嗡嗡......好吧,这只是旋转开始时调用的函数。问题是如何调整框的大小。这个盒子有像按钮,其他元素的内容。 – xpepermint 2011-01-21 21:38:15