2013-05-13 69 views
1

我正在viewcontroller中创建一个项目。我有图像视图,标签和scrollview。但是当我改变方向时,它会以不好的方式对齐?在iOS 5.0中更改方向

有什么办法可以正确对齐吗?另外我的滚动视图不工作。我在storyboard.my控件框架中将代表设置为视图(横向模式)。

book_cover_image.frame=CGRectMake(50,20,250,300); 
    label_book_name.frame=CGRectMake(350,20,500,50); 
    label_book_author.frame=CGRectMake(350,76 , 500, 50); 
    label_book_price.frame=CGRectMake(350,135, 500, 50); 
    image_price_rupees.frame=CGRectMake(100, 330, 22, 16); 
    [buy_button setFrame:CGRectMake(13, 380, 119, 32)]; 
    [preview_button setFrame:CGRectMake(150, 380, 113, 32)]; 
    RecommendedBooksView.frame=CGRectMake(0,400,1024,368); 
    _thumbnailListView.frame=CGRectMake(15, 50, 950,350); 

回答

0

您可能会考虑使用UIView的autoresizingMask属性在循环过程中自动调整视图大小并重新定位视图。

http://www.techpaa.com/2012/05/understanding-uiview-autoresizing.html

如果你想要的autoresizingMask不能做,你可以通过实现自定义每个方向的框架:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration { 
    [UIView animateWithDuration:duration animations:^{ 
     //set new frame properties 
    }]; 
} 
在您的视图控制器