2013-10-04 4 views
5

現在、ボタンをタップすると、UIModalPresentationSheetが表示されます。私はそれがスライドするとき、これの上にナビゲーションバーを追加したいと思います。私はたくさんのことを試しましたが、何も動かないようです。ここで私は現在何をしようとしていると、このエラーを返します。モーダルビューのナビゲーションコントローラ

AthleteAdd *addAthlete = [self.storyboard instantiateViewControllerWithIdentifier:@"addAthlete"]; 
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addAthlete]; 
    //[self.navigationController pushViewController:addAthlete animated:YES]; 

    addAthlete.delegate = self; 
    addAthlete.modalPresentationStyle = UIModalPresentationFormSheet; 
    // UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addAthlete]; 
    [self presentViewController:navigationController animated:YES completion:nil]; 

しかし、モーダルプレゼンテーションシートのフォームを使わずにモーダルにプッシュアップします。ナビゲーションコントローラのサイズを正しく設定するにはどうしたらいいですか?

答えて

12

次のようにコードを変更してください:ここで、あなたは自分自身からaddAthleteを提示しようとしているので

AthleteAdd *addAthlete = [self.storyboard instantiateViewControllerWithIdentifier:@"addAthlete"]; 
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addAthlete]; 

    addAthlete.delegate = self; 
    navigationController.modalPresentationStyle = UIModalPresentationFormSheet; 


    [self presentViewController:navigationController animated:YES completion:nil]; 

。だからこのエラーが発生します。

+0

これは動作しますが、それはもはやmodalsheetpresentation ..です –

+0

は私の編集に見てください。) –

4

addAthleteを格納したnavigationControllerを表示する必要があります。

[self presentViewController:navigationController animated:YES completion:nil]; 
0

現在のビューコントローラー自体からプレゼンテーションしています。

のようなものを試してみて、

[self dismissViewControllerAnimated:YES completion:^{ 
    [self.parentViewController presentViewController: navigationController animated:YES completion:nil]; 
}]; 
関連する問題