tags:

views:

198

answers:

1

any one guide me how to call uipopovercontroller from an uivew

+1  A: 

Hi,

Create a new UIViewController which your popover will show. Lets call it "detailController". To your current view, add an button with a IBAction to it... lets call this action "makeItPop".

Implement the following code:

- (IBAction)makeItPop
{
    UIViewController *detailControllerView = [[detailController alloc] initWithNibName:@"detailController" 
                                                                           bundle:nil]; 

    UIPopoverController* aPopover = [[UIPopoverController alloc] initWithContentViewController:detailControllerView];
    [aPopover setPopoverContentSize:CGSizeMake(320, 320)];
    [detailController release];
    [aPopover presentPopoverFromRect:CGRectMake(200,200,-100,-100) inView:self.view  permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}

If you want to use the UIPopverController delegate, implement it in your header file and add:

[aPopover setDelegate:self];

That should do it. Using different sizes and position will put the box at another location.

Regards, Paul Peelen

Paul Peelen