Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem in showing subview as popover

I want to show the subview of a view in popover. To elaborate,

I have a mainViewController. I hava a subview 'songListView' in this mainViewController. I have a button titled 'list' in the mainViewController' itself. I want to show the songListView in popover on clicking the button 'list'.

So, how should I do this.

like image 713
iPhoneDev Avatar asked Dec 01 '25 01:12

iPhoneDev


1 Answers

You could use the below code as a reference for showing PopOver from a UIButton

-(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 greenColor];
   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];
}
like image 174
Jhaliya - Praveen Sharma Avatar answered Dec 03 '25 02:12

Jhaliya - Praveen Sharma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!