2011-03-24 100 views
1

如何使用特定点上的箭头显示准备好的弹出式菜单(TableView里面)?基本上,我有一个CGPoint screenPointContainer,我想在那里展示我的popover。没有矩形,没有按钮。 只是一个点。CGPoint中的弹出式菜单

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

回答

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]; 
} 
3

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

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

+0

在这种情况下,弹出窗口会产生比实际点击高的点。 – Razp 2011-03-24 12:58:14