故事板UICollectionViewCell显示,然后变为空白

时间:2021-05-20 11:47:22

Problem:

I am working on a UIViewController on my Storyboard/Interface Builder, with a UICollectionView in it that defines a UICollectionViewCell. Everytime I change something in this cell, all its subviews goes to blank white, making it impossible to see anything. Also when I update constraints frame won't move even if I refresh, like the whole interface builder is broken. It's only for this UIViewController, sometimes does it for an other one. Interface Builder Builds show warnings from Pods (I can't help it). I have no broken constraints.

我在Storyboard / Interface Builder上使用UIViewController,其中有一个UICollectionView,用于定义UICollectionViewCell。每当我在这个单元格中更改某些内容时,其所有子视图都会变为空白,从而无法看到任何内容。此外,当我更新约束时,即使我刷新,框架也不会移动,就像整个界面构建器被破坏一样。它只适用于这个UIViewController,有时它会用于另一个。 Interface Builder Builds显示来自Pods的警告(我无法帮助它)。我没有受到限制。

(Very) Temporary solution:

If I quit Xcode, clean, rebuild and re-open the Storyboard, it will be back to "almost" normal (meaning not all views shows properly but at least I can see them and it's not fully white) until I switch to an other file and come back. When I come back to the storyboard will be blank again. Sometimes I have to delete my DerivedData and the cell will display perfect. Only for a few minutes.

如果我退出Xcode,清理,重建并重新打开故事板,它将恢复到“几乎”正常(意味着并非所有视图都显示正常,但至少我可以看到它们并且它不是完全白色),直到我切换到另一个文件然后回来。当我回到故事板时将再次空白。有时我必须删除我的DerivedData,单元格将显示完美。只有几分钟。

Also, I do not have any constraints warnings or anything.

此外,我没有任何约束警告或任何东西。

EDIT: I removed all classes from all the views in the cell, just in case something in my custom views was causing these problems. My views mostly implement layers and gradients so I thought I might have been doing something wrong breaking the IB rendering. On the top of the cell there is a custom UIView that I made, that uses a CAGradientLayer. If I remove the class from this view, the cell will start displaying again. But I can't be sure this is the cause since when I leave the storyboard and come back on it, the cell will be white again. Without having putting back the class in place.

编辑:我从单元格中的所有视图中删除了所有类,以防我的自定义视图中的某些内容导致这些问题。我的观点主要是实现图层和渐变,所以我认为我可能在做错了IB渲染时做错了。在单元格的顶部有一个我自己制作的自定义UIView,它使用了CAGradientLayer。如果我从此视图中删除该类,则该单元格将再次开始显示。但我不能确定这是原因,因为当我离开故事板并回到它上面时,细胞将再次变白。没有把课程放回原位。

EDIT2: I uninstalled and reinstalled Xcode and cocoapods. Updated the pods. Created a new xcworspace.

EDIT2:我卸载并重新安装了Xcode和cocoapods。更新了播客。创建了一个新的xcworspace。

Screenshot

故事板UICollectionViewCell显示,然后变为空白

故事板UICollectionViewCell显示,然后变为空白

Details on my environment

I am using Swift, XCode 9.3, Cocoapods 1.5.0, High Sierre 10.13.4 Feel free to ask any other details My Pods (that generate lots of warnings due to swift 4 compatibility) :

我正在使用Swift,XCode 9.3,Cocoapods 1.5.0,High Sierre 10.13.4随意询问任何其他细节My Pods(由于swift 4兼容性而产生大量警告):

  pod 'FBSDKLoginKit'
  pod 'FBSDKCoreKit'
  pod 'FSPagerView'
  pod 'CropViewController'
  pod 'SwiftLint'
  pod 'Parse'
  pod 'Parse/FacebookUtils'
  pod 'ImagePicker'
  pod 'XLPagerTabStrip', '~> 8.0'
  pod 'Eureka'

3 个解决方案

#1


1  

You should call the super parent in the awakeFromNib method.

您应该在awakeFromNib方法中调用超级父级。

You must call the super implementation of awakeFromNib to give parent classes the opportunity to perform any additional initialization they require.

您必须调用awakeFromNib的超级实现,以便为父类提供执行所需的任何其他初始化的机会。

override func awakeFromNib() {
  super.awakeFromNib()
  setup()
}

#2


1  

Can be one of your Dependency, look at the issues on these dependencies.

可以是您的依赖关系之一,查看这些依赖关系的问题。

Try to remove your dependencies one by one.

尝试逐个删除您的依赖项。

#3


0  

The problem was caused by Cocoapods an Xcode.

这个问题是由Cocoapods和Xcode引起的。

First, I realized by cloning my project on an other machine, that my Xcode was not displaying the Interface Builder errors, but only the warnings.

首先,我通过在另一台机器上克隆我的项目来实现,我的Xcode没有显示Interface Builder错误,只显示了警告。

How to display Interface Builder errors ?

如何显示Interface Builder错误?

On the left pane in Xcode (the one with the file hierarchy), click on the last item looking like a comic bubble. You will see the build, workspace and interface builder errors. My Xcode for some reason would not display anything, so I re-installed for the second time Xcode.

在Xcode的左侧窗格(具有文件层次结构的窗格)中,单击最后一个看起来像漫画气泡的项目。您将看到构建,工作空间和界面构建器错误。我的Xcode由于某种原因不会显示任何内容,所以我第二次重新安装了Xcode。

How to properly re-install Xcode ?

如何正确重新安装Xcode?

Simply delete all those files :

只需删除所有这些文件:

/Applications/Xcode.app
/Library/Preferences/com.apple.dt.Xcode.plist
~/Library/Preferences/com.apple.dt.Xcode.plist
~/Library/Caches/com.apple.dt.Xcode
~/Library/Application Support/Xcode
~/Library/Developer
~/Library/Developer/Xcode
~/Library/Developer/CoreSimulator

Source : How to Completely Uninstall Xcode and Clear All Settings

来源:如何完全卸载Xcode并清除所有设置

Then, Xcode showed me this error :

然后,Xcode向我显示了这个错误:

故事板UICollectionViewCell显示,然后变为空白

Finally, I could confirm that removing the pod related to this framework would stop breaking my storyboard. By looking more on the internet, I found that this is an actual issue related to Frameworks signing, caused by cocoa pods.

最后,我可以确认删除与此框架相关的pod会停止破坏我的故事板。通过在互联网上查看更多内容,我发现这是与可可豆荚造成的框架签名相关的实际问题。

I uninstalled Cocoapods 1.5.0 and re-installed the 1.4.0 version.

我卸载了Cocoapods 1.5.0并重新安装了1.4.0版本。

sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.4.0

Source : Xcode - @IBDesignables - Required code signing missing for X.framework

来源:Xcode - @IBDesignables - X.framework缺少必需的代码签名

All problems fixed.

所有问题都已解决

#1


1  

You should call the super parent in the awakeFromNib method.

您应该在awakeFromNib方法中调用超级父级。

You must call the super implementation of awakeFromNib to give parent classes the opportunity to perform any additional initialization they require.

您必须调用awakeFromNib的超级实现,以便为父类提供执行所需的任何其他初始化的机会。

override func awakeFromNib() {
  super.awakeFromNib()
  setup()
}

#2


1  

Can be one of your Dependency, look at the issues on these dependencies.

可以是您的依赖关系之一,查看这些依赖关系的问题。

Try to remove your dependencies one by one.

尝试逐个删除您的依赖项。

#3


0  

The problem was caused by Cocoapods an Xcode.

这个问题是由Cocoapods和Xcode引起的。

First, I realized by cloning my project on an other machine, that my Xcode was not displaying the Interface Builder errors, but only the warnings.

首先,我通过在另一台机器上克隆我的项目来实现,我的Xcode没有显示Interface Builder错误,只显示了警告。

How to display Interface Builder errors ?

如何显示Interface Builder错误?

On the left pane in Xcode (the one with the file hierarchy), click on the last item looking like a comic bubble. You will see the build, workspace and interface builder errors. My Xcode for some reason would not display anything, so I re-installed for the second time Xcode.

在Xcode的左侧窗格(具有文件层次结构的窗格)中,单击最后一个看起来像漫画气泡的项目。您将看到构建,工作空间和界面构建器错误。我的Xcode由于某种原因不会显示任何内容,所以我第二次重新安装了Xcode。

How to properly re-install Xcode ?

如何正确重新安装Xcode?

Simply delete all those files :

只需删除所有这些文件:

/Applications/Xcode.app
/Library/Preferences/com.apple.dt.Xcode.plist
~/Library/Preferences/com.apple.dt.Xcode.plist
~/Library/Caches/com.apple.dt.Xcode
~/Library/Application Support/Xcode
~/Library/Developer
~/Library/Developer/Xcode
~/Library/Developer/CoreSimulator

Source : How to Completely Uninstall Xcode and Clear All Settings

来源:如何完全卸载Xcode并清除所有设置

Then, Xcode showed me this error :

然后,Xcode向我显示了这个错误:

故事板UICollectionViewCell显示,然后变为空白

Finally, I could confirm that removing the pod related to this framework would stop breaking my storyboard. By looking more on the internet, I found that this is an actual issue related to Frameworks signing, caused by cocoa pods.

最后,我可以确认删除与此框架相关的pod会停止破坏我的故事板。通过在互联网上查看更多内容,我发现这是与可可豆荚造成的框架签名相关的实际问题。

I uninstalled Cocoapods 1.5.0 and re-installed the 1.4.0 version.

我卸载了Cocoapods 1.5.0并重新安装了1.4.0版本。

sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.4.0

Source : Xcode - @IBDesignables - Required code signing missing for X.framework

来源:Xcode - @IBDesignables - X.framework缺少必需的代码签名

All problems fixed.

所有问题都已解决