3

I am not able to set the contentsize with size(650,400).But even i create popoverController with same width & height it is getting created.

No idea what is worry ? On tapping Enter it shows as below

enter image description here

- (IBAction)setButtonTapped:(id)sender
{
     popover *mpopover      =   [[popover alloc] init];

    UINavigationController  *NavController      =   [[UINavigationController alloc] initWithRootViewController:mpopover];

    //NavController.navigationBar.backgroundColor = [UIColor darkGrayColor];
    mPickerPopover  = [[[UIPopoverController alloc] initWithContentViewController:NavController] retain];

    CGSize popoversize      =   CGSizeMake(400, 90);

    [mpopover setparent:mPickerPopover];

    [mpopover setToolBarFrame:popoversize];

    mPickerPopover.popoverContentSize   = popoversize;

    [mPickerPopover presentPopoverFromRect:CGRectMake([sender frame].origin.x, [sender frame].origin.y, 20, 20) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

    [mpopover release];
}

On tapping show button looks like this enter image description here

 -(void)buttonView:(id)sender
 {

  CGSize popoversize        =   CGSizeMake(650, 320);

  [parent setPopoverContentSize:popoversize animated:YES];


  [toolbar setFrame:CGRectMake(0, popoversize.height- 90, popoversize.width, 60)];

  CATransition *transition = [CATransition animation];
  transition.type = kCATransitionPush;
  transition.duration = 1.0f;
  transition.timingFunction = UIViewAnimationCurveEaseInOut;
  [self.view.layer addAnimation:transition forKey:@"transitionViewAnimation"];
  }
Pugalmuni
  • 9,350
  • 8
  • 56
  • 97
Anand
  • 2,086
  • 2
  • 26
  • 44

5 Answers5

2

It's not very clear what you are asking but with popovers you need to make sure you set the popoverContentSize on the content view controller before displaying the popover. Usually I do this in viewDidLoad method of my view controllers that will be used in popovers.

Cory Powers
  • 1,140
  • 8
  • 14
  • It doesn't matter were we initialize popover it works fine.The problem is setting contentsize with size(650,400) after popover appears. – Anand Apr 15 '11 at 02:20
  • I have noticed problems with changing the content size of a popover once it is displayed before, you should be able to just set the size and it will update but that doesn't always seem to be the case. The way I worked around the issue is by calling presentPopoverFromRect again on the popover then it updates to the new size. – Cory Powers Apr 15 '11 at 18:10
1

Consider using:

-(BOOL)splitViewController:(UISplitViewController *)svcontroller shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation 
{
    return NO;
}

This will present the popover in portrait and landscape orientations.

animuson
  • 53,861
  • 28
  • 137
  • 147
Carlos Saltos
  • 1,385
  • 15
  • 15
1

From Apple's documentation:

"the width value you specify must be at least 320 points and no more than 600 points."

Maybe trying to set the width to 650 is the problem.

user449960
  • 11
  • 1
1

I was having a similar problem in that I was unable to change the size of a popover controller during device rotation. I found the information that lead to my solution in a answer to a similar question.

Because I was presenting the popover from a Bar button, UIKit was "trying" to help by adjusting the size of the popover during rotation (because the position of the button might be different after a change to a different device orientation). Even though I knew exactly what size I wanted the popover to be in every case, it wasn't respecting my calls to setPopoverContentSize. My solution was to dismiss the popover in willAnimateRotationToInterfaceOrientation, then re-present the same popover in didRotateFromInterfaceOrientation after setting appropriate values for both contentSizeForViewInPopover and popoverContentSize. IHTH

Community
  • 1
  • 1
Chuck H
  • 7,434
  • 4
  • 31
  • 34
0

I noticed you have a UIViewController called popover which should be shown inside the popoever that you have referenced as mpopover navigate to that class and in the ViewDidLoad Method of the ViewController cycle make sure to add the following code

self.contentSizeForViewInPopover = CGSizeMake(400, 90); // or Any size you like

...&...