【问题标题】:How to make the master view controller and detail view controller in a split view controller push simultaneously如何使拆分视图控制器中的主视图控制器和详细视图控制器同时推送
【发布时间】:2014-05-02 00:04:23
【问题描述】:

如何让一个split view controller中的master view controller和detail view controller同时push到一个split view controller中的另一个master view controller和另一个detail view controller,也就是说如何将一个split view controller推送到另一个拆分视图控制器。 任何帮助或建议将不胜感激。

【问题讨论】:

    标签: uisplitviewcontroller


    【解决方案1】:

    伙计,如果我明白你在问什么。您可以使用通知。示例代码如下:

    在第一个细节视图控制器中,可以添加一个按钮和一个事件:

    UIButton *button ......
    [button addtraget:self action: @selector(pushToSecondDetailView) forControlEvents: UIControlEventTouchUpInside];
    
    -(void) pushToSecondDetailView
    {
      SecondDetailViewController *secondDVC = [[SecondDetailViewController alloc] init];
      [self.navigationController pushViewController:secondDVC animated:YES];
    
      //register notificaton
       [[NSNotificationCenter defaultCenter] postNotificationName:kpushToSecondVCtNotification
                                                        object:nil];
    }
    

    在第一个主视图控制器中:

    //receive natification
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(pushToSecondMasterVC) name:kpushToSecondVCNotification object:nil];
    
    -(void) pushToSecondMasterVC
    {
     SecondRootViewController *secondVC = [[SecondRootViewController alloc]init];
    
    [self.navigationController pushViewController:secondVC animated:YES];
    
    }
    

    最后但同样重要的是,在您的 projectname-Prefix.pch 文件中添加以下代码:

    #define kpushToSecondVCNotification @"kpushToSecondVCNotification"
    

    就是这样,祝你好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-27
      • 1970-01-01
      • 1970-01-01
      • 2015-11-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多