我想从UITableView特定索引中呈现UIPopover。 这是我的代码:
if (indexPath.row == 5) {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
EnginesPopoverController *enginesPopoverController = [[EnginesPopoverController alloc] initWithNibName:@"EnginesPopoverController" bundle:nil];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:enginesPopoverController];
self.popoverController = popover;
popoverController.delegate = self;
[popover release];
[enginesPopoverController release];
CGPoint point = {670, 600};
CGSize size = {450, 216};
[popoverController presentPopoverFromRect:CGRectMake(point.x, point.y, size.width, size.height) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
如果我尝试从UIButton呈现Popover,那就顺利了......
谢谢!
答案 0 :(得分:0)
这就是我的所作所为:
CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath];
CGRect popoverRect = CGRectMake(self.view.bounds.size.width - self.popoverController.popoverContentSize.width,
CGRectGetMidY(cellRect),
1.0, 1.0);
我使用的x
位置将弹窗放在屏幕的右侧。这可能不是你想要的。要查找实际触摸点,您可以使用手势识别器。
作为回报,请尝试回答我的相关问题:Popover's arrow to track an object in a scrollview
答案 1 :(得分:0)
操纵大卫的代码我到达了这个: (我的pop被称为“storytPop”) - 我的popover来自工具栏,我希望下一个tableview显示在右边。
CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath];
[self.storytPop presentPopoverFromRect:cellRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];