当用户触摸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];
答案 0 :(得分: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添加到表视图的0,0位置。你只需要设置popupview的位置。如果你打开弹出窗口,那么选择方法然后会弹出该行。