3

我想从 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,它会顺利...

谢谢!

4

2 回答 2

0

操作 David 的代码我得到了这个:(我的 pop 被称为“storytPop”)-我的弹出窗口来自工具栏,我希望下一个 tableview 显示在右侧。

CGRect cellRect = [self.tableView rectForRowAtIndexPath:indexPath]; 
[self.storytPop presentPopoverFromRect:cellRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
于 2011-02-24T09:26:20.493 回答
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

于 2010-08-09T21:11:44.153 回答