iOS - UITableView的超级视图覆盖了应用程序进入前景时的屏幕

时间:2013-01-23 10:46:29

标签: iphone ios uitableview superview

我有一个UITableView,我正在应用一组过滤器。当我点击“过滤器”按钮时,过滤器会从导航栏下方生成动画。我在这里做的是拿一个我加载的NIB将它添加到UITableView的superview。 当我启动视图时,这非常有效。我能够显示和隐藏过滤器NIB。 但是,在通过点击主页按钮将应用程序发送到后台后,我再次启动应用程序以将其置于前台。 现在我加载并附加到UITableView超级视图的NIB已经接管了屏幕。 tableview隐藏在此视图下方,我可以通过隐藏过滤器NIB看到一小部分命中。 虽然我添加到superview的NIB高度为75,但当它进入前景时我可以看到它的框架现在大小超过400。 有谁有任何想法为什么这可能发生在超级视图? 感谢

我的代码

- (IBAction)filterButtonPressed:(UIBarButtonItem *)sender
{
    //If the filter view is displayed on screen then remove it.
    if(self.filterViewDisplayed == YES){
        [self animateFilterButtonsWithButtonsYOrigin:-75 tableViewYOrigin:-75];
        self.filterViewDisplayed = NO;

    }else {
        //Determine if we should load the FilterButtons XIB
        if(self.filterViewLoaded == NO) {

            self.filterViewLoaded = YES;
            [self.tableView.superview addSubview:self.activityFilter];
        }
        self.filterViewDisplayed = YES;
        //Set the delegate of the ActivityFilter to self so that we can handle callbacks.
        self.activityFilter.delegate = self;

        //Set the intial frame of the filter buttons to be -75 pixels off the top of the screen
        CGRect filterFrame = self.activityFilter.frame;
        filterFrame.origin.y = -75;
        self.activityFilter.frame = filterFrame;

        //Now animate the filter buttons to appear at origin 0.
        [self animateFilterButtonsWithButtonsYOrigin:0 tableViewYOrigin:75];
    }
}

- (void)animateFilterButtonsWithButtonsYOrigin:(CGFloat)yOrigin tableViewYOrigin:(CGFloat)tableViewYOrigin
{
    [UIView animateWithDuration:0.25
                     animations:^{
                         CGRect filterFrame = self.activityFilter.frame;
                         filterFrame.origin.y = yOrigin;
                         self.activityFilter.frame = filterFrame;
                         [self adjustTableViewOriginBy:tableViewYOrigin];
                     }];
}

-(void)adjustTableViewOriginBy:(CGFloat)yOrigin
{
    CGRect tableFrame = self.tableView.frame;
    tableFrame.origin.y += yOrigin;
    self.tableView.frame = tableFrame;
}

截图

  1. 在过滤动画之前
  2. 应用过滤器后
  3. 从后台启动后 - 问题在这里。 Superview占据整个视图
  4. 隐藏过滤器会在superview下面显示tableview
  5. Before Filter animation

    After Filter applied

    After launching from background

    Hiding filter shows UiTableView beneath the superview

1 个答案:

答案 0 :(得分:0)

我在我的应用中使用ECSlidingViewController菜单。我发现这需要顶层视图的屏幕截图,以便看起来像是禁用与视图的交互。结果是顶级视图,即superview,包含我加载的NIB文件。这就是我所看到的。我通过禁用ECSlidingViewController的screencapture函数修复了它。

相关问题