Change preferred content size of PopOverViewController on fly
Asked Answered
H

1

0

I am trying to change the preferred content size of a UIPopOverController from inside the childViewController.

Firstly I present PopOverViewController 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 i.e (DateViewController), I have button which when toggled will call a function

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

This is working fine, but as we know that UIPopOverViewController has arrow, so when I resize the popOverView, the arrow also animates up and down, which I dont want. I cannot show this in image, so please excuse me for that.

Need help

Ranjit.

Homologue answered 23/1, 2015 at 14:58 Comment(0)
W
0

First of all the code you posted won't work, because in else statement you assign CGSizeMake giving only one value while constructing it.

Secondly you can define in which directions you allow for that arrow by specifying popoverArrowDirection property

Woundwort answered 23/1, 2015 at 15:24 Comment(5)
Hey my typing mistake, please check my above question now. Hey I am already inside a VC which is shown as popOver, from here how can I access popOverArrowDirection property.Homologue
the first note was just a side note, the important thing for you is the arrow direction I mentioned :)Woundwort
I have given arrow direction, when I am showing popOverVC. Now I am inside the VC which is shown as popOver. Now how to manage this. And is their any other way to change preferredContentSize?Homologue
manage what setting the arrow direction ? set the property I have mentionedWoundwort
Hello, I think, my question is not clear, so I have made edits, hope you will now understand, what I need.Homologue

© 2022 - 2024 — McMap. All rights reserved.