2012-03-23 17 views
0

私はこのcocos2Dアプリケーションで、横向きの向きのみをサポートしています。あたかもデバイスが縦向きであるかのように、このUIViewが垂直に表示されます。私は2つの質問があります:UIViewの向きが正しくない

  • なぜそれが垂直に表示されているのですか?
  • ビューを手動で回転させなくても正しく表示されますか?ここで

ビューコントローラのコードです:

// this method is called from init 
-(void) addLoadingView {  
     CGSize size = [[CCDirector sharedDirector] winSize]; 

    _blockerView = [[[UIView alloc] 
     initWithFrame: CGRectMake(0, 0, 280, 60)] autorelease]; 
    _blockerView.backgroundColor = [UIColor colorWithWhite: 0.0 alpha: 0.8]; 
    _blockerView.center = CGPointMake(size.width/2, size.height/2); 
    _blockerView.alpha = 0.0; 
    _blockerView.clipsToBounds = YES; 
    if ([_blockerView.layer respondsToSelector: @selector(setCornerRadius:)]) 
     [(id) _blockerView.layer setCornerRadius: 10]; 

    _blockerLabel = [[[UILabel alloc] initWithFrame: CGRectMake(0, 5, _blockerView.bounds.size.width, 15)] autorelease]; 
    _blockerLabel.text = NSLocalizedString(@"Please Wait...", nil); 
    _blockerLabel.backgroundColor = [UIColor clearColor]; 
    _blockerLabel.textColor = [UIColor whiteColor]; 
    _blockerLabel.textAlignment = UITextAlignmentCenter; 
    _blockerLabel.font = [UIFont boldSystemFontOfSize: 15]; 
    [_blockerView addSubview: _blockerLabel]; 

    UIActivityIndicatorView *spinner = [[[UIActivityIndicatorView alloc] 
     initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhite] autorelease]; 

    spinner.center = CGPointMake(_blockerView.bounds.size.width/2, _blockerView.bounds.size.height/2 + 10); 
    [_blockerView addSubview: spinner]; 
    [self.view addSubview: _blockerView]; 
    [spinner startAnimating]; 
} 

-(void) showLoadingGraphics:(NSString*)textInView{ 
    _blockerView.alpha = 1.0; 
    _blockerLabel.text = NSLocalizedString(textInView, nil); 
} 

が更新

私はそれがopenGLViewにそれを追加した場合、それは大丈夫であることが分かりました。

[[[CCDirector sharedDirector] openGLView] addSubview: _blockerView]; 

代わりの

私はその現在のビューは、何らかの形で回転させてしまった疑い

に動作します。

+0

スクリーンショット? _blockerはあなたが話しているビューですか? クイックコメント - 既に特定のフレームを使用して初期化している場合は、_blockerViewの中心を設定する必要はありません。 – sparkFinder

+0

はい、_blockerViewは回転されたものです。私はこのコードを書かなかった。私はここで働いている、笑。しかし、チップをありがとう。 – Jay

答えて

1

ビューコントローラでshouldAutorotateToInterfaceOrientation:メソッドを確認してください。あなたの回答は次のようになります:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || 
      interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 

タブバーコントローラはありますか?もしそうなら、それは潜在的な問題です。タブバーのすべてのビューコントローラは向きを一致させる必要があります。

+0

それはそうではありません。自動回転は上手く、ちょうど回転で描かれます。私はいくつかのスーパービューが回転されたか何かを得たと思う。 – Jay

0

プロジェクトプロパティリストの縦向きでオンにしましたか?

<key>UISupportedInterfaceOrientations</key> 
<array> 
    <string>UIInterfaceOrientationPortrait</string> 
    <string>UIInterfaceOrientationLandscapeRight</string> 
    <string>UIInterfaceOrientationLandscapeLeft</string> 
</array> 
関連する問題