Today Extension height for iPad much larger than specified

此生再无相见时 提交于 2019-12-03 09:17:59

Here's how to achieved this:

  1. You should consider your constraint.

  2. Your widgets default margin insets are not properly configured on the way you desired it, so setting this on your own is the only workaround here by calling 'widgetMarginInsetsForProposedMarginInsets:'

// Update widgets insets

func widgetMarginInsetsForProposedMarginInsets(defaultMarginInsets: UIEdgeInsets) -> UIEdgeInsets {

    println(NSStringFromUIEdgeInsets(defaultMarginInsets))
    return UIEdgeInsetsMake(20, 20, 10, 20)
}

Modified sample file link: Modified file

I was facing the same issue. Have you added bottom padding constraint as shown in the image?

That worked for me.Hope it helps

I had to hardcode the value of the widget on the viewDidLoad delegate method in order to fix this:

import UIKit
import NotificationCenter

class TodayViewController: UIViewController, NCWidgetProviding {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.preferredContentSize = CGSize(width: 0, height: 320)
    }

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!