2012-09-16 3 views
1

나는 거의 반나절 동안 내 머리를 노크했지만 해결책을 알아 내지 못했습니다. 절름발이 인 경우 실례합니다.그래프를 가로로 회전하거나 조정하는 방법은 무엇입니까?

대상 : 장치의 방향에 관계없이 가로 모드로 항상 그래프를 표시하십시오. 내 x 축과 y 축을 this 그림과 같이 표시하고 싶습니다. 더 많은 데이터를 표시하려면 x 축이 y 축보다 공간을 얼마나 잘 사용하는지는 작성자가 어떻게 작성했는지는 언급하지 않았습니다.

내가 지금 uptill있는 것은 : viewDidLoad에서 또한

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
return YES; 
} 

, 나는 내보기 -90도 회전을 시도 : 부하에

self.view.transform = CGAffineTransformMakeRotation(-(M_PI * (90)/180.0)); 

를 내보기는 아래의 경우처럼 보인다 Date은 x 축이고 Calories Burned은 y 축입니다. 내가 시뮬레이터를 회전 할 때

View on Load Figure

, 그것은 매우 이상한 모습을 제공 :

View on Simulator Rotation

내가이 일을 조정할 수있는 방법을 누군가가 말해 주시겠습니까? 고마워.


* 적절한 답변을받은 후 편집 : 내가 언급 할 한가지 더 내가 그림 2에 언급 된 문제를 해결하기 위해 즉, 그냥 쓰기 :

myHostingGraph.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight); 

이 매우 중요하다 선을 더 아름답게 작동하도록합니다. 참고로 : 단지 만 가로로 전체의 UIViewController를 설정하지 왜 stackoverflow.com/a/10954432/437146

답변

1

: 그들은 세로로 설정

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
       return (interfaceOrientation != UIInterfaceOrientationPortrait && interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
    } 
    else return YES; 
} 

그리고 당신이 정말로 원하는 경우, 단지/레이블을 회전 변환 이상으로 이동 귀하의 그래프는 IBOutlet UILabel *yourLabel;yourLabel.center=CGPointMake(yourGraph.center.x, 10);

+0

고맙습니다. 그것은 마술처럼 일했습니다! :) – NightFury

+0

내가 언급하고자하는 또 하나의 점은 그림 2에서 언급 한 문제를 해결하기 위해서는 'myHostingGraph.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);'라고 쓰면된다. 오리엔테이션 작업을보다 아름답게 만드는 것은 매우 중요한 라인입니다. 참조 : http://stackoverflow.com/a/10954432/437146 – NightFury

관련 문제