来自CGPoint的Popover

时间:2011-03-24 12:22:11

标签: xcode ios ipad

如何使用特定点上的箭头显示准备好的popover(TableView内部)?基本上,我有一个CGPoint screenPointContainer,我想在那里显示我的popover。没有矩形,没有按钮。 只需一点。

detailsPop.popoverContentSize = CGSizeMake(250, 300);
CGRect myrect = CGRectMake(screenPointContainer.x, screenPointContainer.y, ??, ??);
[detailsPop presentPopoverFromRect:myrect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

2 个答案:

答案 0 :(得分:3)

你能不能只创建1像素大小的CGRect?这基本上是一个要点:

CGRect myRect = CGRectMake(screenPointContainer.x, screenPointContainer.y, 1, 1);

答案 1 :(得分:1)

我没有找到坐标失真的原因(上部60个单位)并且必须手动编辑坐标,包括方向检查。矩形的H和W均为0。 现在没关系:

    if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation] ==  UIDeviceOrientationLandscapeRight) 
{

        CGRect myrect2 = CGRectMake(screenPointContainer.x+320, screenPointContainer.y+60, 0, 0);
        [detailsPop presentPopoverFromRect:myrect2 inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

} else {

        CGRect myrect2 = CGRectMake(screenPointContainer.x, screenPointContainer.y+60, 0, 0);
        [detailsPop presentPopoverFromRect:myrect2 inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}