我创建了一个弹出窗口来查看我的设置,

if ([popoverController isPopoverVisible]) {
    [popoverController
     dismissPopoverAnimated:YES];
} else {

    UIView* popoverView = [[UIView alloc]
                           initWithFrame:CGRectMake(566, 440, 0, 0)];

    popoverView.backgroundColor = [UIColor blackColor];
    controller1.contentSizeForViewInPopover = CGSizeMake(300, 115);

    popoverController = [[UIPopoverController alloc]
                         initWithContentViewController:controller1];


    [popoverController presentPopoverFromRect:popoverView.frame
                                       inView:self.view
                     permittedArrowDirections:UIPopoverArrowDirectionUp
                                     animated:YES];
}


我的推送操作代码:

UIStoryboard *storyboard = [UIStoryboard
                            storyboardWithName:@"MainStoryboard"
                            bundle:nil];

UIViewController *controller = (UIViewController *)[storyboard
                                                    instantiateViewControllerWithIdentifier:@"PCBViewController"];

[self.navigationController
 pushViewController:controller
 animated:YES];


在我的设置中,弹出框有一些按钮。单击那些按钮,通过推操作打开视图控制器,但是它不起作用。

我的问题是:如何设置弹出式内容的推送动作。

最佳答案

您的视图是从popover呈现的,因此self.navigationController将为nil。

尝试这个

UIStoryboard *storyboard = [UIStoryboard
                            storyboardWithName:@"MainStoryboard"
                            bundle:nil];

UIViewController *controller = (UIViewController *)[storyboard
                                                    instantiateViewControllerWithIdentifier:@"PCBViewController"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
[navigationController
 pushViewController:controller
 animated:YES];

10-05 21:05
查看更多