问题描述
已更新今天iOS 10的扩展名
实现委托方法:
Had updated the today's extension for iOS 10implement the delegate 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];
}];
}
}
一切正常。但是如果我将小部件保持在紧凑模式(显示更多选项)并且如果我重新运行/重新打开小部件屏幕,并且如果我点击显示更多按钮,即使触发委托方法也没有任何反应。我应该按2次显示更多/更少,直到小部件开始扩展。
我也收到这个错误:没有活动的动画块!
everything work fine. But if I leave the widget in compact mode (with show more option available) and if i rerun/reopen the widget screen and if i tapped on Show More button nothing happens even if the delegate method is triggered. I should press 2 time show more/less until widget starts expanding.I also receive this error:No active animation block!
推荐答案
我发现了这个问题。
我编辑了 self.preferredContentSize
即使小部件在紧凑模式。每次更新 preferredContentSize
时,如果 widgetActiveDisplayMode
是 NCWidgetDisplayModeExpanded
I had edited the self.preferredContentSize
even if the widget was in the compact mode.Just check every time when you update the preferredContentSize
if widgetActiveDisplayMode
is NCWidgetDisplayModeExpanded
这篇关于今天的扩展iOS10显示更多/更少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!