How to call UIPopoverController from an UIView on iPad
any one guide me how to call uipopovercontroller from an UIVie开发者_StackOverflow社区w
Create a new UIViewController
which your popover will show. Lets call it "detailController
".
To your current view, add an button with an 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.
精彩评论