Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get a popover frame of specified width and height in ipad

i am using an popover view in my application,when i went through the samples i found how to create a popover view but in the sample code the popover view is getting displayed to whole page. i want the popover frame of specified width and height when i click the button.

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



CGRect popoverRect = [self.view convertRect:[button frame]fromView:[button superview]];
popoverRect.size.width = MIN(popoverRect.size.width, 50);

[self. popoverController 
 presentPopoverFromRect:popoverRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];

so what changes i should make in the above code to get a frame of specified size of width and height.

like image 576
crazy2431 Avatar asked Feb 02 '26 05:02

crazy2431


1 Answers

Account is the class to be displayed. popAccount is its instance. buttonA is the button on which after click the popOver will be displayed.

-(void)viewDidLoad

{
    popAccount = [[Account alloc] init];

        //[popAccount setDelegate:self];

        popOverControllerA = [[UIPopoverController alloc] initWithContentViewController:popAccount];

        popOverControllerA.popoverContentSize = CGSizeMake(200, 200);   

 }   
    -(IBAction)togglePopOverControllerA {

        if ([popOverControllerA isPopoverVisible]) {

            [popOverControllerA dismissPopoverAnimated:YES];

        } else {

            [popOverControllerA presentPopoverFromRect:buttonA.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
        }

    }

Further ask for any query..

like image 140
Anil Kothari Avatar answered Feb 03 '26 17:02

Anil Kothari