将UIViewController显示为没有seguge的Popup

时间:2015-07-08 12:53:57

标签: ios objective-c uiviewcontroller pushviewcontroller

我使用了这个问题的代码Display UIViewController as Popup in iPhone它运行正常,但我不想使用segue,或者我可以说我不能使用segue,因为所有代码都是以编程方式创建的,所以我不能在按钮上设置segue。

我使用了这段代码,但它没有工作

- (IBAction)open:(id)sender {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController *newVC = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"Second"];
    [ViewController setPresentationStyleForSelfController:self presentingController:newVC];
    [self.navigationController pushViewController:newVC animated:YES];

}

编辑1: 弹出后查看

enter image description here

1 个答案:

答案 0 :(得分:0)

您应该检查此VC self.navigationController是否为零。我想你想presentViewController:而不是pushViewController: ...