I am struggling to change the height of my iOS 10 widget in compact mode.
All I have is an empty widget, no views inside it. Still, no matter what I set for the compact height, it seems to ignore it.
Here is my code:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self.extensionContext setWidgetLargestAvailableDisplayMode:NCWidgetDisplayModeExpanded];
}
- (void)widgetActiveDisplayModeDidChange:(NCWidgetDisplayMode)activeDisplayMode withMaximumSize:(CGSize)maxSize{
if (activeDisplayMode == NCWidgetDisplayModeCompact) {
self.preferredContentSize = CGSizeMake(0, 50);
}
else{
self.preferredContentSize = CGSizeMake(0, 200);
}
}
Could this be an issue with beta software? I am on Xcode 8 beta and iOS 10 beta 7.
According to the What's new in Cocoa Touch session from WWDC 2016 (around the 44:00 mark):
Now we have a user controlled size. The compact mode, which is fixed height and the expanded mode which is variable height.
So, it seems that setting a preferredContentSize
for NCWidgetDisplayModeCompact
is completely ignored (the fixed size appears to be 110pts).