2010-12-13 4 views
0

StackOverflow에 대한 첫 번째 질문이므로 지금 당장 답변을 찾으려고했지만 모든 적절한 조치를 취하지 않았다면 실례합니다.XCode에서 Interface Builder Object Coordinates를 설정하십시오.

iPhone이 세로 모드에서 가로 모드로 변경되면 인터페이스 작성기에서 UIView의 여러 객체 좌표를 변경하려고합니다. 그래서 뷰를 축척하고 싶지는 않지만 아이폰이 가로 모드로 바뀌면 모든 객체가 더 잘 맞을 수 있도록 객체를 재정렬하려고합니다. 현재 프로그래밍 방식으로 X, Y 좌표를 설정하는 방법을 찾고 있지만이를 수행하는 더 좋은 방법이 있다면 알려주십시오.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) { 
    /* Move IBOutlets to different X,Y coordinates */ 

} 
return YES; 

답변

2

shouldAutorotateToInterfaceOrientation:은보기가 특정 방향을 지원하는지 여부에 대한 대답으로 사용해야합니다. 객체를 재 배열하려면 willRotateToInterfaceOrientation: 또는 didRotateFromInterfaceOrientation을 사용하십시오.

실제로는 UIView의 하위 클래스를 지정하고 layoutSubviews을 재정의하는 것이 좋습니다.

+0

좋은데, 어떻게 그 대상의 위치가 바뀌겠습니까? –

+0

IB 출구 (http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/IB_UserGuide/CodeIntegration/CodeIntegration.html#//apple_ref/doc/uid/TP40005344-CH18)를 설정했다고 가정합니다. 'self.myLabel.frame = CGRectMake (10, 10, 200, 20)' – Brian

+0

과 같이 객체의 프레임이나 센터를 설정하면됩니다. 고맙습니다! –

관련 문제