快速更改P​​opOverViewController的首选内容大小 [英] Change preferred content size of PopOverViewController on fly

查看:145
本文介绍了快速更改P​​opOverViewController的首选内容大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从childViewController内部更改UIPopOverController的首选内容大小.

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

首先,我以这种方式呈现PopOverViewController

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];

因此在我的childViewController即DateViewController中,我有一个按钮,当切换该按钮时,它将调用一个函数

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);
       }
}

这工作正常,但是我们知道UIPopOverViewController有箭头,所以当我调整popOverView的大小时,箭头也会上下移动动画,这是我不想要的.我无法在图片中显示此图片,因此请原谅.

需要帮助

Ranjit.

推荐答案

首先,您发布的代码将不起作用,因为在else语句中,您分配的CGSizeMake在构造它时仅给出一个值.

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

这篇关于快速更改P​​opOverViewController的首选内容大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆