0

I need to present a UIPopover from dynamically generated UITextFields in a UITableView. They are all tagged uniquely but when I try and use this code the popover just show up in the upper left hand corner:

[self.numbersPopover presentPopoverFromRect:[self.childSkusTable viewWithTag:aTag].frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];

EDIT:
I see I am finding the frame for that tagged item but it is relavant to it's parent cell, in this case the frame of that tagged items is 0,0 for the x,y. How do I get it's position in the main window view?

Slee
  • 27,498
  • 52
  • 145
  • 243

1 Answers1

2

Answering this just incase someone else needs it.

You have to get you UiTextFields position in the UIWindow like so:

UIView *v = [self.view viewWithTag:aTag];
CGPoint pos = [v.superview convertPoint:v.frame.origin toView:nil];

Then I just did this:

[self.numbersPopover presentPopoverFromRect:CGRectMake(pos.x, pos.y, 35, 10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];

The finding positioning code form above came from this questions and answer: iPhone - Get Position of UIView within entire UIWindow

Community
  • 1
  • 1
Slee
  • 27,498
  • 52
  • 145
  • 243