2014-09-20 3 views
2

화면에 프로그래밍 방식으로 프레임 (0, 100, 50, 50)이있는 UIView를 배치하고 자동 크기 조정 마스크를 UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin 및 화면 회전 시작할 때 어떤 이유로 오른쪽 가장자리보기 막대기. 뷰 프레임 (20, 100, 50, 50)을 설정하면 모든 것이 잘 작동합니다.자동 수정 마스크가 올바로 작동하지 않습니다.

내가 뭘 잘못하고 있니?

샘플 코드 : 회전하기 전에

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    UIView *cell = [[UIView alloc] initWithFrame:CGRectMake(0, 100, 50, 50)]; 
    cell.backgroundColor = [UIColor blackColor]; 
    cell.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | 
          UIViewAutoresizingFlexibleLeftMargin; 
    [self.view addSubview:cell]; 
} 
- (NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskAll; 
} 

:

--------------------------- 
|       | 
|=====      | 
|| |      | 
|=====      | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
----------------------------- 
|    o    | 
--------------------------- 

회전 모든 나쁜 일 후 :

------------------------------------------------ 
|           | | 
|          =====| | 
|          | || | 
|          =====| | 
|           | | 
|           | o | 
|           | | 
|           | | 
|           | | 
|           | | 
|           | | 
------------------------------------------------ 

--------------------------- 
|       | 
|      =====| 
|      | || 
|      =====| 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
----------------------------- 
|    o    | 
--------------------------- 

내가 * 전지 = [[

에 UIView를 변경하는 경우 UIView lloc] initWithFrame : CGRectMake (0, 100, 50, 50)];

UIView의 셀에 * = [UIView의 ALLOC] initWithFrame : CGRectMake (20, 100, 50, 50)]; 회전하기 전에

:

--------------------------- 
|       | 
| =====     | 
| | |     | 
| =====     | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
----------------------------- 
|    o    | 
--------------------------- 

회전 모든 것이 잘 작동 후 :

------------------------------------------------- 
|            | | 
| =====          | | 
| | |          | | 
| =====          | | 
|            | | 
|            | o | 
|            | | 
|            | | 
|            | | 
|            | | 
|            | | 
------------------------------------------------- 

--------------------------- 
|       | 
| =====     | 
| | |     | 
| =====     | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
|       | 
----------------------------- 
|    o    | 
--------------------------- 
+0

당신은 원래 X = 0 프레임이 일어날 무엇을 원하는가? –

+0

적어도 장치를 세로 방향으로 되돌릴 때 뷰가 초기 위치로 돌아 가야합니다. 그리고 나는 왜보기가 오른쪽 가장자리에 붙어 있는지 이해하지 못합니까? – Juancho

답변

0

이 시도 :

cell.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | 
         UIViewAutoresizingFlexibleBottomMargin; 
관련 문제