0

特定のフレームCGRectMake(40,50、400、500)でモーダルビューコントローラーとしてaNavControllerを表示しています。これは正常に機能しています。これで、自分自身にボタン(modalViewControllerが表示されるviewcontroller)ができました。そのボタンを押すと、aNavControllerにメッセージを表示する必要があります。しかし、問題は、modalViewControllerを提示しているときです。画面領域全体が淡色表示/無効化されました。そのため、そのボタンを自分でタッチ/クリックすることはできません。

これがViewControllerを提示するための私のコードです。私はここで何かが足りないと思った。助けてください。前もって感謝します。

aNavController.modalPresentationStyle = UIModalPresentationFormSheet;
anavController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:aNavController animated:YES];
aNavController.view.superview.frame = CGRectMake(40,50, 400, 500);
4

3 に答える 3

1

presentModalViewControllerは、モーダルダイアログを作成します。モーダルビューコントローラが起動している場合、モーダルビューが閉じられるまで、ユーザーは親ビューに対して何もできません。

于 2012-07-09T19:34:51.280 に答える
0

問題は、のデリゲートメソッドでモーダルビューを呼び出すUIAlertViewと同時にインスタンス化することです。presentModalViewControllerUIAlertViewclickedButtonAtIndex

そのようです:

- (IBAction)clickedMyButton:(id)sender
{
    UIAlertView *alertView = [[UIAlertView alloc]
                 initWithTitle: @"Title"
                 message: @"Message"
                 delegate:self
                 cancelButtonTitle:@"Close Button"
                 otherButtonTitles:@"Modal Button", @"Some Other Button", nil];
    [alertView show];
}



- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0) {
        NSLog(@"User Selected Cancel");
    }
    else if (buttonIndex == 1) {
        NSLog(@"Modal Button Clicked");
        aNavController.modalPresentationStyle = UIModalPresentationFormSheet;
        anavController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
        [self presentModalViewController:aNavController animated:YES];
        aNavController.view.superview.frame = CGRectMake(40,50, 400, 500);
    }else {
        NSLog(@"Some Other Button Clicked");
    }
}

または、ナビゲーションコントローラの上に表示したい場合はUIAlertView、上記を無視して、ナビゲーションコントローラが- (void)viewDidAppear:(BOOL)animatedメソッドを実行するまでアラートを呼び出すのを待ちます。

また、どうしても必要な場合を除いて、画面の範囲内に収まるようにフレームを変更することをお勧めします。元:CGRectMake(40, 50, 320, 480);

于 2012-07-09T20:09:25.783 に答える
0

最後に、UIModalPresentationFormSheetと同じように機能する問題を回避できます。

[[UIApplication sharedApplication] keyWindow]にサブビューとしてaNavControllerを追加しました。これにより、すべての問題が解決されます。

コメントありがとうございます。

于 2012-07-27T05:13:01.480 に答える