problem in setting PopoverContentSize
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
- (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:mPickerPopo开发者_如何学运维ver];
[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
-(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"];
}
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.
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.
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
Consider using:
-(BOOL)splitViewController:(UISplitViewController *)svcontroller shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
{
return NO;
}
This will present the popover in portrait and landscape orientations.
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
...&...
精彩评论