作者:我是小章丘 | 来源:互联网 | 2023-02-10 16:16
Imtryingtosolveanissuewithmytodaywidget.ItsnotexpandingoniOS10afterpressingShow
I'm trying to solve an issue with my today widget. It's not expanding on iOS10 after pressing "Show more" button. It's size keeps the same all the time.
我正试图解决我今天的小部件的问题。按“显示更多”按钮后,它不会在iOS10上扩展。它的大小始终保持不变。
Here is the code for TodayViewController.swift
这是TodayViewController.swift的代码
import UIKit
import NotificationCenter
class TodayViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
extensionContext?.widgetLargestAvailableDisplayMode = .expanded
}
}
extension TodayViewController: NCWidgetProviding {
func widgetActiveDisplayModeDidChange(activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {
if activeDisplayMode == .expanded {
preferredCOntentSize= CGSize(width: 0, height: 280)
} else {
preferredCOntentSize= maxSize
}
}
}
Any hints please?
有什么提示吗?
1 个解决方案