UIPopoverController: Why doesn't my popover appear where I want?

Simple: In the view, I represent the UIPopoverController in a CGRect using presentPopoverFromRect ... and neither the arrow nor the popover frame even comes close to the coordinates I requested in the rectangle I entered. Any clues? I tried to figure it out myself, but I give up. Here is the code:

if(!myContentController){
    myContentController = [[MyContentController alloc] initWithNibName:myNibName bundle:[NSBundle mainBundle]];
    // This works pretty well. actually when i show the popover
    // i see everything inside as it supposed to.
}
if(!popover){
   popover = [[UIPopoverController alloc] initWithContentViewController:myContentController];
}
else{
    [popover setContentController:myContentController];
}
popover.delegate = self;
CGPoint touchPointInView = [self touchPoint];//This is working fine too.I've been checking with NSLog.
popover.ContentSize = myPopoverSize;//In this case {320,480}
 [popover presentPopoverFromRect:CGRectMake(touchPoint.x,touchPoint.y,myPopoverSize.width,myPopverSize.height)
                          inView:self.view
        permittedArrowDirections:UIPopoverArrowDirectionAny
                        animated:YES];

What will happen next? popover does not show where it should be. If I go through {0,0}, it is displayed in the middle of the screen, as if the size of the view was (768,512). I checked all the sizes of the view, and they are all in order, frame, border, etc ..... Does anyone know what I'm doing wrong?

+5
source share
2

CGRect, presentPopoverFromRect, , popover next ( ). , popover .

, popover , 1,1. , CGRectMake presentPopoverFromRect :

CGRectMake(touchPoint.x,touchPoint.y,1,1)

, touchPoint inView (self.view ).


, (, ):

  • setContentController ContentViewController
  • popover.ContentSize popover.popoverContentSize
  • myPopverSize.height myPopoverSize.height( 1)
+14

. , - tableView. , UIPopover TableView, . :

[_popoverController presentPopoverFromBarButtonItem:self.navigationItem.rightBarButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
+1

All Articles