2013-05-27 5 views
2

이 문제는 무수히 자주 있었으며 해결 방법을 찾을 수 없습니다. 나는 Xcode 프로젝트 (빈 프로젝트 - NO XIB 's!)에서 일하고있다. 나는 내 방향을 가로로 설정 :보기가 잘리지 않음 (가로 방향과 세로 방향)

enter image description here

하지만이 일어나고 유지 :

enter image description here

뷰가 차단되고 있습니다. 내가 뭘 할지라도 적절한 크기로 설정되지 않는 것 같습니다. 어떤 이유로 가로 세로를 사용하여 가로로 뷰를 표시합니다. 누구든지이 문제를 해결하는 방법을 알고 있습니까? 또한 방향을 가로 방향으로 만 제한하려고합니다.

UPDATE 보기는 차단을하지 않는 경우 높이와 너비와 768 I 하드 코드 1024. 이것은 분명히 끔찍한 해결책이지만, 나는 그것을 이해할 수 없다. 아무도 해결책에 대해 알고 있습니까?

+0

당신이 UISplitViewController를 사용하고 있습니까 : 여기

은 예입니다? – KishoreK

+0

아니요. 그냥 UIViewController입니다. – tentmaking

답변

0

내가 대답을 : 앱 위임에서

- (NSUInteger) supportedInterfaceOrientations{ 
return UIInterfaceOrientationMaskLandscape|UIInterfaceOrientationLandscapeRight; 
} 

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ 
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation); 
} 

이 기능을 추가! 내 친구 중 한 명이 나를 도와주었습니다.

뷰는 표시 될 때까지 방향이 지정되지 않으므로 뷰에 구성 요소를 추가하고 기본값 이외의 다른 방향으로 향하게하려는 경우 (세로 인 것으로 의심되는 경우) 해당 구성 요소를 다음 위치에 추가해야합니다. -(void)viewDidAppear:(BOOL)animated. viewDidLoad 메서드 내에서 뷰에 여러 구성 요소를 추가 한 메서드를 호출했지만 해당 메서드가 호출 될 때 뷰가 나타나지 않고 방향이 설정되지 않았습니다. 내 초기화 코드를 viewDidAppear 방법으로 이동하면 문제가 해결됩니다.

-(void)viewDidAppear:(BOOL)animated 
{ 
    [super viewDidLoad]; 

    //Probably dont want to draw stuff in here, but if you did, it would adhere to the 
    //correct orientation! 
    CAShapeLayer *layer = [CAShapeLayer layer]; 
    layer.backgroundColor = [UIColor blueColor].CGColor; 
    layer.anchorPoint = CGPointMake(0, 0); 
    layer.bounds = CGRectMake(0, 0, self.view.bounds.size.width, 300); 
    [self.view.layer addSublayer:layer]; 

    //Call methods from here 
    [self initializeScrollView]; 
    [self addItemToScrollView]; 
    [self addGraphToView]; 
} 
1

에서 설정하는 rooViewController를 응용 프로그램 대리인 클래스에서 확인하십시오. 확인 당신이 누구의 목적은 rootViewController로 설정하고이 뷰 컨트롤러 클래스에 적절한 허용 방향을 반환됩니다

- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ 

return UIInterfaceOrientationMaskLandscape|UIInterfaceOrientationLandscapeRight; 
} 
+0

나는 그 방법들을 추가했지만 아무 것도하지 않았다. 나는 그들이 자동적으로 부름 받았다고 생각하니? 나는 그 (것)들을 직접적으로 불렀다. – tentmaking

+0

는 또한 애플 대리자 자체에 추가 - (NSUInteger) 응용 프로그램 : (UIApplication *) 응용 프로그램의 supportedInterfaceOrientationsForWindow : (UIWindow *) 창 { 반환 UIInterfaceOrientationMaskLandscape | UIInterfaceOrientationLandscapeRight; } – Kedar

+0

그 중 하나가 작동하지 않았다. 이 벌레가 나를 죽이고있어. 나는 오리엔테이션을 설정하는 것이 너무 어려웠다는 것을 깨닫지 못했습니다. – tentmaking

관련 문제