Ios 显示的ModalView显示在自定义视图中,从中调用

Ios 显示的ModalView显示在自定义视图中,从中调用,ios,uinavigationbar,modalviewcontroller,presentmodalviewcontroller,custom-view,Ios,Uinavigationbar,Modalviewcontroller,Presentmodalviewcontroller,Custom View,上图显示了我的应用程序的架构。。我在1和2中创建了一个自定义视图来显示UIViewController3中的内容 在VC1和VC2中触摸自定义视图时,我想直接跳到VC4 自定义视图是UIView,我在界面生成器中将其更改为UIControl以接收触摸事件 我在自定义视图类touchevent方法中使用了以下代码 - (IBAction)customViewTouched:(id)sender { VC4 *nextController = [[VC4 alloc] in

上图显示了我的应用程序的架构。。我在1和2中创建了一个自定义视图来显示UIViewController3中的内容

在VC1和VC2中触摸自定义视图时,我想直接跳到VC4

自定义视图是UIView,我在界面生成器中将其更改为UIControl以接收触摸事件

我在自定义视图类touchevent方法中使用了以下代码

    - (IBAction)customViewTouched:(id)sender {

        VC4 *nextController = [[VC4 alloc] initWithNibName:@"VC4" bundle:nil];

        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:nextController];

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

        navigationController.navigationBar.tintColor = [UIColor blackColor];
        navigationController.navigationBar.topItem.title = @"My Title";



        navigationController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]
 initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(cancel)];
        navigationController.navigationItem.hidesBackButton = FALSE;

       // navigationController.navigationBar.backItem.title = @"back";

    }

  • 在VC2中触摸自定义视图时(正确调用该视图)-VC4弹出,但仅在自定义视图中

  • 我也无法在导航栏上找到后退按钮。(正如其他stackoverflow回答中所建议的,我还尝试在ViewDidLoad中设置自定义视图的标题)

  • 3.我在VC1中创建了一个customView大小的虚拟UIButton,并将customView放入其中。。这样我就可以处理VC1本身的触摸事件了。。这会造成性能问题吗

    [myCustomViewButton addTarget:self action:@selector(myEventHandler) forControlEvents: UIControlEventTouchUpInside];
    
    当我使用上述代码时,它不会抛出任何错误,但myEventHandler方法从未被调用。。使用“UIViewController”类名时,在addTarget而不是“self”中,它会引发一个错误

    我不知道该怎么处理这件事。。非常感谢您的帮助:)

    我假设未提及的VC3管理您的自定义视图: 将[self-presentVC]更改为[self.parentVC-presentVC]


    您从中演示VC4的VC3作为子级嵌入在VC1和VC2中

    [self.parentViewController presentViewController:navigationController动画:是完成:无];我试过了,但什么也没发生。我们不能在VC1中处理customview上的触摸事件吗?我的意思是不将调用发送回customview类“-(iAction)customViewTouched:(id)sender方法。。另外,供参考,在带有PageController的scrollView中堆叠10个customView,我是否应在VC1中创建一个customView大小的虚拟UIButton,并将customView放入其中。。这样我就可以处理VC1本身的触摸事件了。。这会造成性能问题吗?