I know this type of question has been asked before, but none of them is able to solve my problem.
I want to set the Today's Extension height to be variable.
For this I have included the below code as suggested in related posts:
override func viewDidLoad()
{
super.viewDidLoad()
if #available(iOSApplicationExtension 10.0, *)
{
self.extensionContext?.widgetLargestAvailableDisplayMode = .expanded
}
else
{
// Fallback on earlier versions
}
}
@available(iOSApplicationExtension 10.0, *)
func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize)
{
if activeDisplayMode == .expanded
{
preferredContentSize = CGSize(width: 0.0, height: 200.0)
}
else
{
preferredContentSize = maxSize
}
}
The problem I am facing is, even after setting widgetLargestAvailableDisplayMode
to .expanded
in viewDidLoad
, when the protocol method widgetActiveDisplayModeDidChange
is called, it is still giving me the activeDisplayMode
as .compact
.
What else need to be done to make the widget work right in iOS 10?