Today iOS10 extension Show more / Less

Updated today's extension for iOS 10 to implement the delegation method:

-(void)widgetActiveDisplayModeDidChange:(NCWidgetDisplayMode)activeDisplayMode withMaximumSize:(CGSize)maxSize { if (activeDisplayMode == NCWidgetDisplayModeCompact){ [UIView animateWithDuration:0.25 animations:^{ self.preferredContentSize = maxSize; [self.view layoutIfNeeded]; }]; } else if (activeDisplayMode == NCWidgetDisplayModeExpanded){ newHeight = [self getNewWidgetHeight]; [UIView animateWithDuration:0.25 animations:^{ self.preferredContentSize = CGSizeMake(0, newHeight); [self.view layoutIfNeeded]; }]; } } 

everything is working fine. But if I leave the widget in compact mode (if there are more options), and if I re-run / close the widget screen, and if I clicked the "Show more" button, nothing will happen even if the delegate method is initiated. I have to click 2 times more / less until the widget starts expanding. I also get this error: No active animation block!

+6
source share
2 answers

I found a problem.

I edited self.preferredContentSize , even if the widget was in compact mode. Just check every time you update preferredContentSize if widgetActiveDisplayMode is NCWidgetDisplayModeExpanded

+13
source

I had the same problem and then I looked through the storyboard and realized that the "User Preferred Explicit Size" option was turned on.

enter image description here

Disabling this option worked for me.

+2
source

Source: https://habr.com/ru/post/1011677/


All Articles