【问题标题】:Hide MasterViewController when the cells are clicked单击单元格时隐藏 MasterViewController
【发布时间】:2014-04-09 18:09:10
【问题描述】:

我有一个 Master Detail View ipad 应用程序。当我单击单元格并加载某些内容时,我想关闭/隐藏masterViewController。当我单击表格单元格时,我正在DetailViewController 上加载一个单独的视图控制器。当我不在detailView 上加载另一个视图时,它工作得非常好。单击表格行后,如何关闭masterViewController

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{


    [_detailViewController.navigationController pushViewController:[self.storyboard     instantiateViewControllerWithIdentifier:@"ABCViewController"] animated:YES];
}

【问题讨论】:

    标签: ios objective-c ipad uisplitviewcontroller master-detail


    【解决方案1】:

    我找到了解决办法。如果有人在这里需要这个答案,那就是:

    注册以获取有关您详细视图的通知。

    1)在您的详细视图上注册以获取通知。

    • (void) viewDidLoad

      {

      //for showing loginview
      [[NSNotificationCenter defaultCenter] addObserver:self  
      selector:@selector(dismissPop) name:@"MASTERROWSELECTED" object:nil];
      

      } 2)在您对 didSelectRowAtIndexPath 的主视图中执行此操作;

    • (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

       //do normal things you usually do
      
      //post notification that row is selected and you need to dismiss popover.
      
      [[NSNotificationCenter defaultCenter] postNotificationName:@"MASTERROWSELECTED" 
       object:nil];
      

      } 3) 在你的详细视图上写下这个方法。

    • (void)dismissPop {

      如果(self.interfaceOrientation == UIInterfaceOrientationPortrait) {

           //self.popover is your reference to master view pop 
           if([self.popover isPopoverVisible])
           {
               [self.popover dismissPopoverAnimated:YES];
           }
      

      }

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-02
      • 1970-01-01
      • 2017-12-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多