0

I have a UITableView that I am applying a set of filters on. The filters animate from below the navigation bar when I tap the "Filter" button. What I am doing here is taking a NIB that I loaded an adding it to the UITableView's superview. This works perfectly when I launch the view. I am able to show and hide the filter NIB. However, after the app has been sent to the background by hitting the home button, I then launch the app again to bring it into the foreground. Now the NIB that I loaded and attached to the superview of the UITableView has taken over the screen. The tableview is hidden beneath this view and I can see a small section of hit by hiding the filter NIB. Eventhough my NIB that I added to the superview has a height of 75, when it comes into the foreground I can see that its frame now has a size of over 400. Has anyone got any ideas as to why this could be happening to the superview? Thanks

My Code

- (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;
}

Screenshots

  1. Before Filter animation
  2. After filter applied
  3. After launching from background - PROBLEM here. Superview takes up entire view
  4. Hiding filter reveals tableview beneath the superview

Before Filter animation

After Filter applied

After launching from background

Hiding filter shows UiTableView beneath the superview

Brian Boyle
  • 2,849
  • 5
  • 27
  • 35

1 Answers1

0

I am using ECSlidingViewController for the menu in my app. I've discovered that this takes a screenshot of the top level view in order to look like its disabling the interaction with the view. The result of this was that the top level view i.e. superview, contained the NIB file that I loaded. This is what I was seeing. I've fixed it by disabling the screencapture function of ECSlidingViewController.

Brian Boyle
  • 2,849
  • 5
  • 27
  • 35