开发者

Popover from a CGPoint

How to display a prepared popover (TableView inside) with the arrow on a specific point? Basically, I have a CGPoint screenPointContainer and I want to show my popover there. No rectangles, no buttons. Just a single point.

detailsPop.popoverContentSize = CGSizeMake(250, 300);
CGRect myrect = CGRectMake(screenPointCon开发者_运维问答tainer.x, screenPointContainer.y, ??, ??);
[detailsPop presentPopoverFromRect:myrect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];


Can you not just create a CGRect with a 1 pixel size? Which would basically be a point:

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


I didn't find the reason of that coordinate distortion (60 units upper) and had to manually edit the coordinates, including orientation checks. Rectangle's H and W are both 0. Now it is OK:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜