iOS - tableview 上的 PopUpViewController 出现在顶部

iOS - PopUpViewController on tableview appears on top

我使用 NMPopUpView 在用户触摸 tableview 行时显示弹出窗口。 当我滚动 tableview 并触摸一行时,问题就出现了,弹出窗口出现在 tableview 的顶部。

当用户使用以下代码触摸行时,我通过跳转到表视图的顶部解决了这个问题:

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

然后我滚动到用户关闭弹出窗口时的初始点:

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

但这不是绝对专业的解决方案。

这是我用来调用弹出窗口的代码:

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];

谢谢。

解决方案:

要有滚动的位置视图:

[self.popViewController showInView:self.navigationController.view withImage:image withMessage:bg animated:YES];
   - (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];
       }
    });
  }

在 popupcontroller.m 文件中已经写到它是将子视图添加到 tableview.so 显然它将弹出视图添加到 table 视图的 0,0 位置。您只需设置 popupview.If 的位置,然后在 select 方法中打开弹出窗口,然后在该行显示弹出窗口。