iOS10小部件“显示更多"“显示较少"漏洞 [英] iOS10 widget "Show more" "Show less" bug

查看:43
本文介绍了iOS10小部件“显示更多"“显示较少"漏洞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为iOS 10实现了新的小部件,并使用以下代码为其设置了高度:

I have implemented the new widget for iOS 10 and I have used the following code to set the height for it:

@available(iOSApplicationExtension 10.0, *)
func widgetActiveDisplayModeDidChange(activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {
    if activeDisplayMode == NCWidgetDisplayMode.Compact {
        self.preferredContentSize = CGSizeMake(0.0, 350.0)
    }
    else if activeDisplayMode == NCWidgetDisplayMode.Expanded {
        self.preferredContentSize = desiredSize
    }

}

运行正常,但是我遇到的问题是使用显示更多" 显示较少" 按钮.它们并不总是响应,我经常不得不多次单击以触发它们.我想念什么吗?我是否需要添加除以上代码之外的其他代码来处理高度?

And it´s working fine, but my issue is with the "Show more" and "Show less" buttons. They don't always respond and I do very often have to click more than once to trigger them. I´m I missing something? Do I have to add more than the above code to handle the height?

推荐答案

Swift 3:

func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {
    if (activeDisplayMode == NCWidgetDisplayMode.compact) {
        UIView.animate(withDuration: 0.25, animations: { () -> Void in
            self.preferredContentSize = yourFixSize
        }, completion: nil)

    }
    else {
        UIView.animate(withDuration: 0.25, animations: { () -> Void in
        self.preferredContentSize = yourMaxSize
        }, completion: nil)
    }
}

这篇关于iOS10小部件“显示更多"“显示较少"漏洞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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