2012-01-23 6 views
0

私はtransitionstyleに以下のコードでTransitionstyleはモーダル

_viewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 

を定義するには、以下のステートメントを使用していますが、モーダル誰もが知っている

@property (nonatomic, assign) UIModalTransitionStyle *modalTransitionStyle; 
@synthesize modalTransitionStyle; 


self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]autorelease]; 

[self.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 

_viewController = [[ModalViewController alloc] init]; 

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:_viewController]; 

UIBarButtonItem * button = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemDone target:self action:@selector(dismissView:)] autorelease]; 

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:_viewController]; 

UIBarButtonItem * button = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemDone target:self action:@selector(dismissView:)] autorelease]; 

[_viewController.navigationItem setLeftBarButtonItem:button animated:YES]; 

navigationController.navigationBar.tintColor = [UIColor brownColor]; 

_viewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 

[self.navigationController presentModalViewController:_viewController animated:YES]; 

それを提示しながら、上記のステートメントは、水平にひっくり返すされていません提示しましたそれはなぜそうであるか。いつまでもプログラム的にコード化されています。

ご協力ありがとうございます。

答えて

1

間違った方法。可読性とメンテナンス性を向上させるために、コードを確認することをお勧めします。

... 
[aButton addTarget:self 
      action:@selector(dismissView:) 
    forControlEvents:UIControlEventTouchUpInside]; 
... 

あなたは次のようにあなたの新しいのViewControllerを表示するために、セレクタメソッドを書くことができます:

、あなたがボタンに関連付けられたターゲット・アクションでのViewControllerをしたことを、このようなものを想定

- (void)dismissView:(id)sender { 
    SecondViewController *secondVC = [[SecondViewController alloc] init]; 
    secondVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
    [self presentModalViewController:secondVC animated:YES]; 
    [secondVC release]; 
} 
2

ここでは混乱している名前がたくさんあります。

AFAICT、_viewControllerは、navigationControllerのルートビューコントローラです。しかし、あなたはself.viewControllerを参照しています...これは同じView Controllerですか?もしそうなら、どうしてアクセサーメソッドを一貫して使用していないのですか?そうでない場合は、適切なビューコントローラ([self viewController]と_viewController)でモーダルトランジションスタイルを設定していることがわかりません。

(あなたはそれを貼り付けるとき、それは、より合理的な方法で表示されるようにコードをフォーマットする上ところで、ください仕事。)問題にアプローチする

+0

私はそれを指摘しました。それを指摘していただきありがとうございます。しかし、まだそれは動作していません。 – user1120133

+0

OK、変更内容を反映した更新コードを投稿してください。@synthesize lines ...一見すると、物事は合理的だと思われます。 –

関連する問題