crazy2431
crazy2431

Reputation: 801

setting postion of popover view in ipad

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

Answers (3)

Ankit Srivastava
Ankit Srivastava

Reputation: 12405

[popoverController presentPopoverFromRect:[sender frame] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

this will do the trick..

Upvotes: 2

alloc_iNit
alloc_iNit

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

Tendulkar
Tendulkar

Reputation: 5540

Change this line

[popoverController presentPopoverFromRect:[sender bounds] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

Upvotes: 0

Related Questions