2013-08-24 3 views
0

비슷한 질문이 몇 가지 있지만 나는 여전히 적절한 해결책을 찾지 못했습니다. 우리가 볼 수있는사용자 지정 UIView 회전하는 동안 크기 조정

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    CustomView *cv = [(CustomView *) [CustomView alloc] initWithFrame:self.view.frame]; 
    [self.view addSubview: cv]; 
} 

랜드 스케이프 모드에서 :

enter image description here

어떻게

@interface CustomView : UIView 

//.. 

- (id)initWithFrame:(CGRect)frame 
{ 
    self = [super initWithFrame:frame]; 
    if (self) { 
     [self setBackgroundColor:[UIColor redColor]]; 

    } 
    return self; 
} 

및보기 컨트롤러 : 난 그냥 사용자 지정보기로 테스트 프로젝트를 만들었습니다 그것을 해결하기 위해? 나는 layoutSubviews에 대해 알고 있지만, 1. 회전 중에는 호출되지 않았습니다. 2. 뷰의 크기를 어떻게 조정할 수 있습니까?

+0

에서 iOS 5 및 회전하면서 –

+0

이 도움이 될 선택을 취소 자동 크기의 서브 뷰를하려고 매우 다른 iOS6가있을 수 있습니다 – wasim

답변

2

자동 크기 조정 마스크를 설정하려고합니다.

CustomView *cv = [(CustomView *) [CustomView alloc] initWithFrame:self.view.frame]; 
cv.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin; 
[self.view addSubview: cv]; 

또한 자동 레이아웃을 살펴

https://developer.apple.com/library/ios/recipes/xcode_help-interface_builder/articles/UnderstandingAutolayout.html

감사합니다,

관련 문제