Reputation: 801
I am using a POPover View in my application where i have a action method,in that i am implementing popover view code.
I have a Button when i click on button popover View appears with table view,clicking on the cell the Cell data displays on the label.
What my requirement is when i click on the button the popover view is getting displayed on LEFT TOP corner,whereas button is Right Top Corner of the screen.i want to set the popover frame below the button on click so please correct me where i am going wrong.
-(IBAction) settingsGo:(id) sender{
NSLog(@"Go");
if (self.popoverController == nil)
{
PopOver *lang = [[PopOver alloc]
initWithNibName:@"PopOver" bundle:[NSBundle mainBundle]];
UIPopoverController *popOver =
[[UIPopoverController alloc]initWithContentViewController:lang];
popOver.delegate = self;
[lang release];
self.popoverController = popOver;
[popOver release];
}
[popoverController setPopoverContentSize:CGSizeMake(250, 150)];
[popoverController presentPopoverFromRect:Button.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
Upvotes: 1
Views: 3254
Reputation: 12405
[popoverController presentPopoverFromRect:[sender frame] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
this will do the trick..
Upvotes: 2
Reputation: 5183
This will help you out.
To set
UIButton *btnAction; // A button to which UIPopoverController will belong.
CGRect popoverFrame = btnAction.frame;
[popoverController setPopoverContentSize:CGSizeMake(320, 355) animated:NO];
[popoverController presentPopoverFromRect:popoverFrame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
setPopoverContentSize will set the size of UIPopoverController.
Upvotes: 3
Reputation: 5540
Change this line
[popoverController presentPopoverFromRect:[sender bounds] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Upvotes: 0