Today extension show more and show less option to expand the tableView iOS swift

Problem:

In iOS today extension it will show in notification area with show less and show more option.Based on that i want to display minimum one cell on if it will be in show more condition and display full data if it will be in show less mode.


Solution:

Below function we can change the height based on the user action

    func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {

if (activeDisplayMode == NCWidgetDisplayMode.compact) {
            self.preferredContentSize = maxSize
        }
        else {
            //expanded
            self.preferredContentSize = CGSize(width: maxSize.width, height: CGFloat(CGFloat(list.count*65  // you can replace the 65 with your cell height size
                )))
        }

}

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift