【问题标题】:Trying to dismiss table when a selection has been made in popup View在弹出视图中进行选择时尝试关闭表格
【发布时间】:2014-02-25 03:37:25
【问题描述】:

我从我的 ViewController.m 中调用它

当我从弹出窗口中选择一行时,我试图调用下面的控制器

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

    ...

    TSPopoverController *dismiss = [[TSPopoverController alloc]init];
    [dismiss dismissPopoverAnimatd:YES];



}

在类中找到:TSPopoverController.m

- (void) dismissPopoverAnimatd:(BOOL)animated
{
    if (self.view) {
        if(animated) {
            [UIView animateWithDuration:0.2
                                  delay:0.0
                                options:UIViewAnimationOptionAllowAnimatedContent
                             animations:^{
                                 popoverView.alpha = 0;
                             }
                             completion:^(BOOL finished) {
                                 [self.contentViewController viewDidDisappear:animated];
                                 popoverView=nil;
                                 [self.view removeFromSuperview];
                                 self.contentViewController = nil;
                                 self.titleText = nil;
                                 self.titleColor = nil;
                                 self.titleFont = nil;
                             }
             ];
        }else{
            [self.contentViewController viewDidDisappear:animated];
            popoverView=nil;
            [self.view removeFromSuperview];
            self.contentViewController = nil;
            self.titleText = nil;
            self.titleColor = nil;
            self.titleFont = nil;
        }

    }
}

当我尝试调用该方法时:

- (void) dismissPopoverAnimatd:(BOOL)animated

什么都没有发生。当我在 popovertable 中做出选择时,谁能指出我如何让​​这个 popOverView 消失的正确方向?

【问题讨论】:

    标签: objective-c xcode uitableview


    【解决方案1】:

    我认为问题在于您在 didSelectRowAtIndexPath 方法中再次实例化弹出框。相反,您应该创建一个成员并使用它来解雇。看到这个answer

    【讨论】:

      【解决方案2】:

      我通过添加解决了它:

      @interface ViewController ()<UITableViewDataSource, UITableViewDelegate>
      {  
          TSPopoverController *popoverController;   
      }
      

      然后我只是在下面的函数中调用它:

      - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
      {
      
          ...
      
          [popoverController dismissPopoverAnimatd:YES];
      
      }
      

      感谢@xoail 引导我朝着正确的方向前进!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-07-13
        • 1970-01-01
        • 2013-03-12
        • 1970-01-01
        相关资源
        最近更新 更多