How to add the UIView into UIPopoverViewController
Asked
Active
Viewed 4,925 times
3 Answers
4
-(void) buttonAction:(id)sender {
//build our custom popover view
UIViewController* popoverContent = [[UIViewController alloc]
init];
UIView* popoverView = [[UIView alloc]
initWithFrame:CGRectMake(0, 0, 200, 300)];
popoverView.backgroundColor = [UIColor whiteColor];
popoverContent.view = popoverView;
//resize the popover view shown
//in the current view to the view's size
popoverContent.contentSizeForViewInPopover =
CGSizeMake(200, 300);
//create a popover controller
self.popoverController = [[UIPopoverController alloc]
initWithContentViewController:popoverContent];
//present the popover view non-modal with a
//refrence to the button pressed within the current view
[self.popoverController presentPopoverFromRect:popoverButton.frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
//release the popover content
[popoverView release];
[popoverContent release];
}
This will add the view to your UIPopoverViewController

kiran
- 4,285
- 7
- 53
- 98
2
You can check the following link below to get some idea as to how to do this
Are there examples of how to use UIPopoverController on iOS?

Community
- 1
- 1

Sharanya K M
- 1,805
- 4
- 23
- 44
0
Try the below Code:
if (mycontroller == nil) {
MyController * viewController = [[MyController alloc] initWithNibName:@"ControllerView" bundle:nil];
mycontroller = viewController;
PopoverController = [[UIPopoverController alloc] initWithContentViewController:self.mycontroller];
PopoverController.delegate = self;
}
[PopoverController presentPopoverFromRect:CGRectMake(260, 120, 10, 10) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

Sharme
- 625
- 4
- 10
- 28