我有一個擴展名,我已經將裸露的骨骼取下來,它將自己置於不正確的狀態,它會在摺疊時顯示「顯示更少」。iOS - Today Extension'show more'&'show less'state incorrect。摺疊顯示'顯示較少' - 需要多次按下才能修復
這是在兩種情況下
- 發生我擴大與「顯示更多」的擴展名,然後離開 屏幕。我打開另一個應用程序,然後返回到擴展。 展開的擴展程序明顯地塌陷在我面前,但仍然 說「顯示較少」
- 我推送一個新的構建以測試更改。它會從之前擴大, 當新的建設推動它變成倒塌,並說「節目少」
我也試過有另一部分有效(天氣)與它擴大,它始終保持擴張一旦擴張,而我的擴展正在崩潰並顯示錯誤的狀態。
發生這種情況時,無論天氣小部件是否存在。
當我在代碼中放置斷點時,在步驟#1中再次調用ViewDidLoad。
下面是代碼,我一點一點地刪除了所有內容,直到這是所有剩下的問題。
class TodayController: UICollectionViewController, NCWidgetProviding {
let reuseIdentifier = "TimeGridCell"
override func viewDidLoad() {
super.viewDidLoad()
self.extensionContext?.widgetLargestAvailableDisplayMode = NCWidgetDisplayMode.expanded
}
override func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
override func collectionView(_ collectionView: UICollectionView,
numberOfItemsInSection section: Int) -> Int {
return 3
}
override func collectionView(_ collectionView: UICollectionView,
cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier,
for: indexPath) as! ArtistTimeGridTableViewCell
cell.nameLabel.text = "blah blah"
return cell
}
func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {
if activeDisplayMode == .expanded {
self.preferredContentSize = (self.collectionView?.contentSize)!
} else if activeDisplayMode == .compact {
self.preferredContentSize = maxSize
}
}
}
需要注意的是,如果我刪除self.extensionContext?.widgetLargestAvailableDisplayMode = NCWidgetDisplayMode.expanded
然後我沒有得到展開或摺疊好,所以它需要的選項。
下面是問題的圖像。第一個圖像是正確的,第二個是不正確的。
你有沒有想過這個?有相同的問題.. – anto0522
我的答案在下面解決了這個問題,但不知道爲什麼這是必需的修復。我忘了回來並且回答以前回答,所以我現在已經完成了。 – Ben987654