2012-05-16 3 views
2

저는 지금 내 ipad 응용 프로그램의 인터페이스를 디자인하고 있는데, 저는 rootview의 중심에보기를 넣고 싶습니다. 내 코드는 다음과 같습니다어떤 방향으로보기 센터를 넣을 수 있습니까?

CGRect ret = CGRectMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds), bounds.size.width/2,  bounds.size.height/2); 

newViewController.view.frame = ret; 
newViewController.view.center = self.view.center; 

self.newViewController = newViewController; 
[self.view addSubview:_newViewController.view]; 

결과는 내가 아래 원하는 것입니다 :

enter image description here

하지만 난 가로로 회전 할 때, 그것은으로 전환 :

enter image description here

내가 설정 한대로 센터에 보관되지 않는 이유를 알고 싶습니다. 어떻게 작동시킬 수 있습니까? 감사!

답변

3
youView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin| 
               UIViewAutoresizingFlexibleBottomMargin| 
               UIViewAutoresizingFlexibleLeftMargin| 
               UIViewAutoresizingFlexibleRightMargin; 
youView.autoresizesSubviews= YES; 
1

사용 자동 크기 조정 마스크는 센터에 보관하는

당신이 다음과 같이 XIBs 당신의 파단에 대한 마스크를 만들어 사용하는 경우
+0

본 내용 http://www.iphonedevsdk.com/forum/iphone-sdk-development/79917-uiviewcontroller-segmentcontrol.html – Saad

2

: 여기

Center without resizing of subviews

나 :

Center with resizing of subview

코드를 사용하려면 @adali에 의해 게시 된 것을 사용하십시오.

관련 문제