如何以编程方式调整模式视图的大小(SWIFT) [英] Howto Size the Modal View programmatically (SWIFT)

查看:67
本文介绍了如何以编程方式调整模式视图的大小(SWIFT)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想在现有的主UIViewController/UIView上显示一个小选项对话框,以便在iPad上看到一个小对话框,在后台看到一个主视图.

I simply want to present a small option dialog over an existing main UIViewController/UIView , so that on an IPad I would see a small Dialog and in the Background I will see the Main View.

我设法以模态视图样式显示了UIViewController/UIView,如下所示:

I managed to show a UIViewController/UIView in a modal view style as follow:

func showoptions(){

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let controller = storyboard.instantiateViewControllerWithIdentifier("Options") as! UIViewController

    controller.modalPresentationStyle = UIModalPresentationStyle.Popover

    let popoverPresentationController = controller.popoverPresentationController

    // result is an optional (but should not be nil if modalPresentationStyle is popover)
    if let _popoverPresentationController = popoverPresentationController {

        // set the view from which to pop up
        _popoverPresentationController.sourceView = self.view;

        //_popoverPresentationController.sourceRect = CGRectMake(60, 100, 500, 500)
        //_popoverPresentationController. .setPopoverContentSize(CGSizeMake(550, 600), animated: true)
        //_popoverPresentationController.sourceView.sizeToFit();

        // present (id iPhone it is a modal automatic full screen)
        self.presentViewController(controller, animated: true, completion: nil)
    }
}

但是我仍然有一些问题: 1.如何摆脱边框上显示的箭头. 2.如何调整此模式视图的大小.它显示的很小,我想使其适合UIControllerView/UIView中最大的控件.

But I have still some issues: 1. Howto get rid of the arrow shown at the border. 2. Howto size this modal view. It is shown to small and I would like to fit it to the largest controls in the UIControllerView/UIView.

有什么帮助吗?

推荐答案

  1. 尝试将_popoverPresentationController.permittedArrowDirections更改为空选项集
  2. 更改controller.preferredContentSize以匹配您想要的尺寸
  1. Try changing _popoverPresentationController.permittedArrowDirections to empty option set
  2. Change controller.preferredContentSize to match your desired size

这篇关于如何以编程方式调整模式视图的大小(SWIFT)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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