【问题标题】:iOS - PopUpViewController on tableview appears on topiOS - 表格视图上的 PopUpViewController 出现在顶部
【发布时间】:2015-04-09 14:26:17
【问题描述】:

当用户触摸 tableview 行时,我使用 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];

【问题讨论】:

  • 如果使用 UITableViewCell 的视图来显示弹窗会发生什么?
  • 很遗憾没有

标签: ios objective-c uitableview popup


【解决方案1】:
   - (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 显然它将 popupview 添加到 table view 的 0,0 位置。您只需设置弹出视图的位置。如果您在选择方法中打开弹出窗口,则在该行上显示弹出窗口。

【讨论】:

  • 是的,我从 didSelectRowAtIndexPath 调用弹出窗口,但在行位置上它不显示弹出窗口。我找到了一个解决方案,它在编辑中。非常感谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多