How to show "Show More" button in today widget (similar to news app as attached here)? I found this on Apple but there are some changes in swift 3 / iOS 10. This seems to be like something new in iOS 10.
Asked
Active
Viewed 3,186 times
2
-
2@TwoStraws I think you were mean not to share the answer but just pointing to paid tutorial. Stackoverflow is not the place for you! – user1140780 Sep 06 '16 at 22:01
-
That's why I posted a comment, not an answer. Furthermore, your question breaks Stack Overflow's posting rules, which is why it has two votes to close – asking for links to tutorials is considered too broad. – TwoStraws Sep 06 '16 at 22:04
-
Possible duplicate of [What is the height of the new iOS 10 Today Widget/Extension?](http://stackoverflow.com/questions/38129047/what-is-the-height-of-the-new-ios-10-today-widget-extension) – MadProgrammer Nov 04 '16 at 21:35
1 Answers
8
This code did the trick of showing "Show More"
override func viewDidLoad() {
super.viewDidLoad()
self.preferredContentSize = CGSize(width: 320, height: CGFloat(items.count)*121 + 44)
if #available(iOSApplicationExtension 10.0, *) {
self.extensionContext?.widgetLargestAvailableDisplayMode = .expanded
} else {
// Fallback on earlier versions
}
}
// For iOS 10
@available(iOS 10.0, *)
@available(iOSApplicationExtension 10.0, *)
func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {
self.preferredContentSize = (activeDisplayMode == .expanded) ? CGSize(width: 320, height: CGFloat(items.count)*121 + 44) : CGSize(width: maxSize.width, height: 110)
}

user1140780
- 988
- 2
- 13
- 29