2013-05-13 39 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 
    }]; 
} 
在您的視圖控制器