It seems that the height of widget is limited in iOS 10.
How to resize the height of widget in iOS 10?
I had the same problem. Trying to do this didn't work:
- (void)widgetActiveDisplayModeDidChange:(NCWidgetDisplayMode)activeDisplayMode withMaximumSize:(CGSize)maxSize {
if(activeDisplayMode == NCWidgetDisplayModeExpanded) {
self.preferredContentSize = myPreferredSize;
}
}
The widget would just stubbornly refuse to resize.
Replacing it with this seemed to do the trick:
- (void)widgetActiveDisplayModeDidChange:(NCWidgetDisplayMode)activeDisplayMode withMaximumSize:(CGSize)maxSize {
if(activeDisplayMode == NCWidgetDisplayModeExpanded) {
self.preferredContentSize = maxSize; // ***??
self.preferredContentSize = myPreferredSize;
}
}
Presto! Why did this work? I have no idea... I'd file a radar, but I'm 99.7% sure that every single radar just gets automatically printed out on an old Apple LaserWriter, directly into a recycling bin which is then promptly set ablaze.
If you will use it like this you will understant
func widgetActiveDisplayModeDidChange(activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {
if activeDisplayMode == NCWidgetDisplayMode.Expanded {
self.preferredContentSize = CGSizeMake(maxSize.width, yourHeight)
}else if activeDisplayMode == NCWidgetDisplayMode.Compact{
self.preferredContentSize = maxSize
}
}
I'm having the same issue. But i found this app "USAGE WIDGET" can set higher height at compact mode. Any idea how can do this ?
The "USAGE WIDGET" app hasn't been updated since November 2015. That means it cannot possibly be compiled against iOS 10 and Xcode 8 and they are simply getting backward compatibility behaviour, even when run on iOS 10.
pls. help me in my case i can't see Show more button, i am trying like below code format.
didload{
[self.extensionContext setWidgetLargestAvailableDisplayMode:NCWidgetDisplayModeCompact];
}
- (void)widgetActiveDisplayModeDidChange:(NCWidgetDisplayMode)activeDisplayMode withMaximumSize:(CGSize)maxSize{
if (activeDisplayMode == NCWidgetDisplayModeCompact) {
self.preferredContentSize = maxSize;
}
else
self.preferredContentSize = CGSizeMake(maxSize.width, 200);
}
I got the basic widget expanding properly, however, I can't seem to resize it when looking at it on the 3D touch shortcut menu. There isn't a show more option. Has anyone found a way to address that case?
It looks like you're setting the maximum widget size to the compact size.
Change:
[self.extensionContext setWidgetLargestAvailableDisplayMode:NCWidgetDisplayModeCompact];
To:
[self.extensionContext setWidgetLargestAvailableDisplayMode:NCWidgetDisplayModeExpanded];
Hello JLaser,
I am trying both way but i am not see button.
any key added in info.plist file.?
Hello JLaser,
I am uninstall app and agin install then i'll see button so thank you very much.
Some time geeting on simulator but when i am checking on other simulator then not displyed and also i'll run application in device but not displayed.
I've read this thread and I'm glad for the input it provides. However, I still havent got it 100% working to get the height adjusted using auto layouts in "expanded" mode.
In one sample app I've created (https://github.com/everlof/TodayExtensionSample) it will adjust the height correctly according to auto layouts when the extension is started in .expanded-mode but, when toggling between .compact and .expanded modes, it will simply not adjust correctly once .expanded is selected again.
Anyone have any hints or tips?