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];

但它以模态方式将其推高,并且没有模态演示表形式。我怎样才能使导航控制器的大小正确?

4

3 回答 3

12

Try to change your code like this :

    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];

Because here, you try to present addAthlete from itself. So you get this error.

于 2013-10-04T13:52:15.970 回答
4

You should present navigationController in which you encased your addAthlete.

[self presentViewController:navigationController animated:YES completion:nil];
于 2013-10-04T13:52:13.563 回答
0

您正在从当前视图控制器本身进行演示。

尝试类似的东西,

[self dismissViewControllerAnimated:YES completion:^{
   [self.parentViewController presentViewController: navigationController animated:YES completion:nil];
}];
于 2013-10-04T13:55:26.213 回答