Resize your preferred PopOverViewController content on the fly

I am trying to change the preferred size of the contents of a UIPopOverController from within a childViewController.

First, I present PopOverViewController in this way

DateViewController *dateView = [[DatePickerViewController alloc] initWithNibName:@"DateViewController" bundle:nil]; UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:dateView]; m_tableCell = (NotesCell *)[m_tableView cellForRowAtIndexPath:indexPath]; popViewController = [[UIPopoverController alloc] initWithContentViewController:navController]; popViewController.backgroundColor = [[AppManager instance].themeManager navigationBarColor]; popViewController.delegate = self; //the rectangle here is the frame of the object that presents the popover, //in this case, the UIButton… CGRect popRect = CGRectMake(m_tableCell.customView.frame.origin.x, m_tableCell.customView.frame.origin.y, m_tableCell.customView.frame.size.width, m_tableCell.customView.frame.size.height); [popViewController presentPopoverFromRect:popRect inView:m_tableCell permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES]; 

So, inside my childViewController ie (DateViewController), I have a button that when called will call a function

  - (void)toggleButton { if(small) { self.presentingViewController.presentedViewController.preferredContentSize = CGSizeMake(320,485); } else { self.presentingViewController.presentedViewController.preferredContentSize = CGSizeMake(320,320); } } 

This works fine, but as we know, the UIPopOverViewController has an arrow, so when I resize the popOverView, the arrow also animates up and down, which I don't want. I cannot show this in the image, so please excuse me for this.

Help is needed

Ranjit.

0
ios uipopovercontroller
Jan 23 '15 at
source share
1 answer

First of all, the code you posted will not work, because in the else statement, you assign CGSizeMake, giving only one value when it is created.

Secondly, you can determine in which directions you are allowing this arrow by specifying the popoverArrowDirection property

0
Jan 23 '15 at 15:24
source share



All Articles