今天Widget扩展高度 - iOS10 [英] Today Widget Extension Height - iOS10

查看:413
本文介绍了今天Widget扩展高度 - iOS10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法为紧凑模式设置今日小部件视图模式的高度。无论我设定什么价值。它将窗口小部件的高度设置为默认值。扩展模式工作正常,值正确设置并反映在窗口小部件中。
我已经在我的viewDidLoad()方法中添加了这一行。

The height for the Today's widget view mode cannot be set for compact Mode. No matter whatever value I set. It sets the height of the widget to a default value. The expanded mode works perfect and the value is properly set and reflected in the widget. I have already added this line in my viewDidLoad() method.

self.extensionContext?.widgetLargestAvailableDisplayMode = .expanded

这是代码。 maxSize的值也不能更改为常量。

Here is the code. The value of maxSize cannot be changed too as its a constant.

func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {

        //self.preferredContentSize = (activeDisplayMode == .compact) ? maxSize : CGSize(width: maxSize.width, height: 300)

        if activeDisplayMode == NCWidgetDisplayMode.compact
        {
             self.preferredContentSize = CGSize(width: maxSize.width, height: 300)
        }
        else
        {
            self.preferredContentSize = CGSize(width: maxSize.width, height: 560)
        }
}


推荐答案

iOS 10中小部件的高度正好是110英寸紧凑模式。它可以在扩展模式下设置为您想要的任何高度,但在紧凑模式下,它将始终为110并且不能被覆盖。

The height of the widget in iOS 10 is exactly 110 in compact mode. It can be set to whatever height you want in expanded mode, but in compact mode it will always be 110 and that can't be overwritten.

这篇关于今天Widget扩展高度 - iOS10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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