質問

一時的なスライドインビューを別のView Controllerからロードしようとしています。私のアプリケーションのView Controllerは構造化されています:

Application > Tab Bar Controller > TabBarItem > View Controller

このView Controllerには、一時ビューをロードするメソッドを正常に起動するボタンがあります:

- (IBAction)displayTimePickerViewForDayButton:(id)sender {

    NSLog(@"displayTimePickerViewForDayButton method entered.");

    // create the selector view controller and become the delegate
    WOTimePickerViewController *tpvc = [[WOTimePickerViewController alloc] initWithNibName:@"WOTimePickerView" bundle:nil];
    tpvc.delegate = self;
    tpvc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

    [self presentModalViewController:tpvc animated:YES];
    [tpvc release];
}

WOTimePickerViewControllerがinitメソッドから正常に戻っていることを確認しましたが、ビューがviewDidLoadメソッドに入りません。

したがって、IBのビューを見ると、VCの「ビュー」に接続されているように見えます。プロパティ。 (IBから)シミュレーターでビューを実行すると、正しくレンダリングされます。

XCODEからアプリを実行すると、ビューに移動してボタンをクリックすると、空白の白い画面が表示されます(これは、ロードするビューの白い背景ではないことに注意してください)。

役に立ちましたか?

解決

このようにする必要があります。

WOTimePickerViewController *tpvc = [[WOTimePickerViewController alloc] initWithNibName:@"WOTimePickerView" bundle:nil];
    tpvc.delegate = self;
UINavigationController *navCntrlr = [[UINavigationController alloc] initWithRootViewController:tpvc];
    navCntrlr.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

    [self.navigationController presentModalViewController:tpvc animated:YES];
    [tpvc release];

しかし、あなたが見逃している重要なことは、あなたがそれを正しくしていないことです。

次のようにする必要があります:

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

また、modalViewコントローラーを閉じる場合は、次のようにする必要があります。

[self.navigationController dismissModalViewControllerAnimated:YES];

他のヒント

View ControllerのmodalTransitionStyleは、そのView Controllerから 表示されるモーダルビューに適用されると思います。したがって、UIModalTransitionStyleCoverVerticalトランジションを使用してモーダルコントローラーを表示する場合は、新しいビューコントローラーではなく、親ビューコントローラー(self)でmodalTransitionStyleプロパティを設定する必要があります。

modalTransitionStyleを使用した経験はありませんが、ビューを読み込む前にそのプロパティを設定すると問題が発生する可能性がありますか?コメントアウトしてみます...

すべてがIBで正しく設定されているようです。 File's OwnerがView Controllerであり、View Outletがビューにバインドされている限り、正常に動作するはずです。

役立つこと、

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top