开发者

UIPopover - What is the prescribed method of changing the frame size of subviews in to contentViewController.view?

I'm not having any success trying to change the frame size or the开发者_StackOverflow中文版 hidden property of views in the contentViewController of my UIPopover. I tried to just alter the frame size of a subview of the contentViewController.view programmatically, but I couldn't alter it. Whatever frame the xib initialized it retained. Now I'm tryin 2 subviews with correct frame sizes for each device orientation, and useing the hidden property to make the view with the correct frame size visible. The xib initially has each ".hidden:YES". I'm not able to use ".hidden:NO" make one of them visible.

Specifically I've a UIImageView in the popover that I want as large as possible in each orientation, while retaining the aspect ratio of the picture it contains.

Some code...

UIInterfaceOrientation interfaceOrientation = [self interfaceOrientation];

// If a saveOrPrintPopover is not already showing, create it.
if(self.saveOrPrintPopover){
    [self   closeSaveOrPrintPopover];

    keyImageView.image = appDelegate.lineImage;
    appDelegate.lineImage = NULL;
    content.printView.image = NULL;
}else{
                    ////////    UIPopoverController created here !
    saveOrPrintPopover = [[UIPopoverController alloc] initWithContentViewController:content];
    content.view.frame = CGRectMake(0, 0, 1024, 748);

    SaveOrPrintViewController *cntrler = (SaveOrPrintViewController *)saveOrPrintPopover.contentViewController;
    if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
        saveOrPrintPopover.popoverContentSize = CGSizeMake(748, 940);
        cntrler.landscapeBackingView.hidden = YES;
        cntrler.portraitBackingView.hidden = NO;
    }
    else {
        saveOrPrintPopover.popoverContentSize = CGSizeMake(984, 664);
        cntrler.landscapeBackingView.hidden = NO;
        cntrler.portraitBackingView.hidden = YES;

    }
    [content.view   setNeedsLayout];
    [content.view   layoutIfNeeded];

    saveOrPrintPopover.delegate = self;

    appDelegate.lineImage = keyImageView.image;
    keyImageView.image = NULL;
}
[self   showPopoverFromBarButtonItem];


You can change size of popover:

[saveOrPrintPopover setPopoverContentSize:CGSizeMake(320, 560)];

And your content view should be configured properly to autoresize.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜