Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS10 widget "Show more" "Show less" bug

I have implemented the new widget for iOS 10 and I have used the following code to set the height for it:

@available(iOSApplicationExtension 10.0, *)
func widgetActiveDisplayModeDidChange(activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {
    if activeDisplayMode == NCWidgetDisplayMode.Compact {
        self.preferredContentSize = CGSizeMake(0.0, 350.0)
    }
    else if activeDisplayMode == NCWidgetDisplayMode.Expanded {
        self.preferredContentSize = desiredSize
    }

}

And it´s working fine, but my issue is with the "Show more" and "Show less" buttons. They don't always respond and I do very often have to click more than once to trigger them. I´m I missing something? Do I have to add more than the above code to handle the height?

like image 299
user6876645 Avatar asked Nov 27 '25 00:11

user6876645


2 Answers

I had the same issue , the problem was that i had updated the preferredContentSize even if the widget was in the compact mode.

Try to check every place where you update the preferredContentSize and update the size only if the if widgetActiveDisplayMode is NCWidgetDisplayModeExpanded

like image 118
Constantin Saulenco Avatar answered Nov 29 '25 16:11

Constantin Saulenco


Swift 3:

func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {
    if (activeDisplayMode == NCWidgetDisplayMode.compact) {
        UIView.animate(withDuration: 0.25, animations: { () -> Void in
            self.preferredContentSize = yourFixSize
        }, completion: nil)

    }
    else {
        UIView.animate(withDuration: 0.25, animations: { () -> Void in
        self.preferredContentSize = yourMaxSize
        }, completion: nil)
    }
}
like image 31
odemolliens Avatar answered Nov 29 '25 15:11

odemolliens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!