0

私はこのコードを持っています:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if( UIInterfaceOrientationIsLandscape(toInterfaceOrientation) )
{
    [[NSBundle mainBundle] loadNibNamed:@"ChatViewController-landscape" owner:self options:nil];

}else {

    [[NSBundle mainBundle] loadNibNamed:@"ChatViewController" owner:self options:nil];

}
}

if(UIInterfaceOrientationIsLandscape(toInterfaceOrientation)行にブレークポイントを設定しましたが、初めてそのコード行に入力されませんでした。電話を回すと、その時間と後続のメソッドが呼び出されます。そのメソッドを呼び出すにはどうすればよいですか。初めて?

4

1 に答える 1

0

初めてviewdidloadで方向を確認し、それに応じてnibファイルをロードする必要があると思います。そのために、willRotateToInterfaceOrientationとviewDiDロードから呼び出すことができる単一のメソッドを作成できます。

[[UIDevicecurrentDevice]方向]これにより現在の方向が得られます

于 2012-07-05T10:14:00.580 に答える