Iphone UIPopoverController超过UITableViewCell
我想通过编程在表视图中选择一行,然后显示我的弹出框,让箭头指向单元格 当表格没有滚动时,此代码可以正常工作,对于滚动表格视图,弹出箭头的位置不正确Iphone UIPopoverController超过UITableViewCell,iphone,ios,ipad,uitableview,uipopovercontroller,Iphone,Ios,Ipad,Uitableview,Uipopovercontroller,我想通过编程在表视图中选择一行,然后显示我的弹出框,让箭头指向单元格 当表格没有滚动时,此代码可以正常工作,对于滚动表格视图,弹出箭头的位置不正确 [self.EventsTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionMiddle
[self.EventsTableView selectRowAtIndexPath:indexPath
animated:YES
scrollPosition:UITableViewScrollPositionMiddle];
[popoverController presentPopoverFromRect:CGRectOffset(cell.frame, 0, cell.frame.size.height + self.EventsTableView.contentOffset)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionLeft
animated:YES];
感谢您的帮助您应该将单元格作为视图传递。您很可能希望传递rect的单元格边界(cell.bounds,而不是cell.frame)。当用户向下滚动列表时,上述方法似乎不适用于我。找到单元格相对于滚动量的位置是个窍门
CGRect rect = [tableView convertRect:[tableView rectForRowAtIndexPath:indexPath]
toView:tableView];
[popoverController presentPopoverFromRect:rect
inView:tableView
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
正确,答案很简单:[popoverController presentPopoverFromRect:cell.bounds inView:cell permittedArrowDirections:UIPopOverErrorDirectionLeft animated:YES];谢谢。我还是需要处理看不见的行!您的意思是当单元格以不可见的方式滚动时?在这种情况下,您可能希望使用
scrollToRowAtIndexPath:atScrollPosition:animated:
将其移动到视图中。