【问题标题】:NotificationCenter height changes automatically in iOS 11iOS 11 中的 NotificationCenter 高度自动更改
【发布时间】:2017-10-03 07:39:19
【问题描述】:

我遇到了问题,例如,一旦您单击小部件中的显示更多按钮,如果您打开应用程序并保持背景,然后去查看小部件,那么高度将会改变并覆盖窗口。

请查看附件图片:

我该如何解决这个问题?

更新:高度问题已修复,但我面临宽度问题。

【问题讨论】:

    标签: ios notifications widget ios11 xcode9


    【解决方案1】:

    设置你的viewController的preferredContentSize

    self.preferredContentSize = CGSizeMake(self.preferredContentSize.width, yourViewSizeHeight);
    

    【讨论】:

      【解决方案2】:

      我发布我的解决方案来解决这个问题:

       func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {
              guard activeDisplayMode == .expanded else {
                  preferredContentSize = maxSize
                  return
              }
              guard didLayoutOnce else {
      
                  let oldPreferredContentSize = preferredContentSize
                  ***preferredContentSize = maxSize** (To fix issue I removed this line of code)*
                  preferredContentSize = oldPreferredContentSize
                  return
              }
      
              let collectionViewSize = phrasesCollectionView.contentSize
              preferredContentSize = maxSize
              if collectionViewSize.height < maxSize.height {
                  preferredContentSize = collectionViewSize
              }
          }
      

      【讨论】:

        猜你喜欢
        • 2023-03-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-12-14
        • 2017-11-07
        相关资源
        最近更新 更多