Kerberos
Kerberos

Reputation: 4166

iOS - PopUpViewController on tableview appears on top

I use the NMPopUpView to show a popup when the user touch on a tableview row. The problem borns when I scroll the tableview and I touch on a row, the popup appears on the top of the tableview.

I worked around the problem with a jump to the top of the tableview when the user touches the row with this code:

[self.tableView setContentOffset:CGPointZero animated:NO];

and then I scroll to the initial point when the user close the popup with:

[self.tableView scrollToRowAtIndexPath:indexPath
                     atScrollPosition:UITableViewScrollPositionTop
                             animated:YES];

But it isn't absolutely a professional solution.

This is the code that I use to call the popup:

self.popViewController = [[PopUpViewController alloc] initWithNibName:@"PopUpViewController" bundle:nil];
    [self.popViewController setTitle:@"This is a popup view"];
[self.popViewController showInView:self.tableView withImage:image withMessage:bg animated:YES];

Thanks.

SOLUTION:

To have the position view of the scrolling:

[self.popViewController showInView:self.navigationController.view withImage:image withMessage:bg animated:YES];

Upvotes: 0

Views: 306

Answers (1)

Bhoomi Jagani
Bhoomi Jagani

Reputation: 2423

   - (void)showInView:(UIView *)aView withImage:(UIImage *)image withMessage:(NSString *)message animated:(BOOL)animated
 {
       dispatch_async(dispatch_get_main_queue(), ^{
       [aView addSubview:self.view];
       self.logoImg.image = image;
        self.messageLabel.text = message;
      if (animated) {
        [self showAnimate];
       }
    });
  }

In popupcontroller.m file it's already written that it's add subview to tableview.so obviously it add popupview to 0,0 position of table view. You have to only set position of popupview.If you open popup in did select method then show pop up on that row.

Upvotes: 1

Related Questions