1

在我的应用程序中,我展示了一个模态视图。在模态视图中,我拍摄了一个包含表格视图和按钮的视图(Extraview)。

从这个按钮,我打开一个包含视图(LeftsideView)的弹出视图。

-(IBAction)popOverBtnPressed:(id)sender
{
    LeftSideVCViewController *popUp=[[LeftSideVCViewController alloc] initWithNibName:@"LeftSideVCViewController" bundle:nil];



    popView = [[UIPopoverController alloc]initWithContentViewController:popUp];
    popView.delegate =self;

    [popView setPopoverContentSize:CGSizeMake(300, 700)];
    [popView presentPopoverFromRect:CGRectMake(150,30,20,40) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

}

在此处输入图像描述 在此处输入图像描述

现在,我想取消选择左侧视图表行的模式视图。我怎样才能做到这一点。

4

3 回答 3

2

在您的问题中提出 PopOver 是一个不同的类,而驳回方法是一个不同的类所以你需要NSNotificationCenter像下面这样实现:-

在您的ViewDidLoad方法中的 PopOVer 创建类中添加通知:-

- (void)viewDidLoad
{

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(dismisPopoverInnerPageTeam:)
                                                 name:@"InnerPop"
                                               object:nil];


    [super viewDidLoad];

}

-(void)dismisPopoverInnerPageTeam:(NSNotification *)notification {

    [yourPopOver dismissPopoverAnimated:YES];
}

现在您只需要从您的LeftSideVCViewControllerUITableView Delegate方法中调用此方法didSelectRowAtIndexPath,例如:-

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
     [[NSNotificationCenter defaultCenter] postNotificationName:@"InnerPop" object:self];

}

希望对你有帮助:)

于 2013-01-09T06:58:29.930 回答
0

试试这个:

[popoverControllerdismissPopoverAnimated:YES];

于 2013-01-09T06:47:24.840 回答
0

我解决了这个如下:

注册后通知。

您必须首先关闭弹出框,然后关闭呈现的模式视图。

-(void)dismissModal:(NSNotification *)notification
{

     [popView dismissPopoverAnimated:YES];
   [self dismissViewControllerAnimated:YES completion:nil];


}
于 2013-01-09T07:44:32.420 回答