2010-11-26 14 views
0

私は作成し、ipadアプリケーションを作成しました。 私はウィンドウベースのアプリケーションを使い、2つのビューコントローラ(loginviewcontroller、detailviewcontroler)を追加しました。どちらも独自のXIBを持っています。 appdelegate applicationdidfinishlaunchメソッドのloginviewcontrollerオブジェクトが追加されました。私は2つのビュー間を行き来するコードを書いていました。ここにコードがあります。オリエンテーションの問題

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  

    // Override point for customization after application launch. 
    Login *mylogin = [[Loginviewcontroller alloc] init]; 
    [window addSubview:mylogin.view]; 
    //detailview *tv=[[detailviewcontroller alloc] init]; 
    // [window addSubview:tv.view]; 
    [self.window makeKeyAndVisible]; 

    return YES; 
} 

問題はwillrotatetointerfaceorientation方法は、私がdetailviewcontrollerにいる場合でも、loginviewcontrollerクラスからのみ実行されることです。

チケットビューをappdelegateに追加すると、detailviewcontrollerからwillrotatetointerfaceorientationメソッドが実行されるため、要約するとappdelegateに追加されたオブジェクトのみからwillrotatetointerfaceorientationメソッドが実行されます。

どのようにして2つのView Controllerをそれぞれ独自のwillrotatetointerfaceorientationメソッドを実行させますか?

答えて

0

のUIViewControllerは、メソッドを持ってい

  • (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

オーバーライドあなたの両方のViewControllerクラスでこの方法(すなわち(loginviewcontroller、detailviewcontroler)

書き込み、これをコード

- (BOOL)shouldAutorotateToInterfaceオリエンテーション:(UIInterfaceOrientation)interfaceOrientation { //ローテーション中にあなたのコードを書く

return Yes;

}

0

回転メッセージは最上位ビューのコントローラにのみ送信されています。適切な方法で手動で転送する必要があります。

関連する問題