Why don't my views show up in Storyboards and

2019-01-19 04:15发布

enter image description here

I am experiencing a weird bug in Storyboards.

I set up a UITableViewController with prototype cells and set some autolayout constraints. Everything fine until here.

Then, I had to move the whole project directory into another folder. This is a normal action I believe that shouldn't lead to any problems since the app and all the files are pretty much self-contained.

However, since I moved the project, the prototype cells in the UITableView are shown empty within my Storyboard, but the subviews are still showing up in the left pane where all the scenes and views are shown... Only that they are greyed out (see the screenshot)... Does anyone know what this means? I also looked into the XML of the Storyboard file, but everything seemed normal to me in there...

Any ideas?

EDIT: Strange thing also is that the IBOutlets from the custom classes still are set and link to the views in the storyboard... but only in the left pane, not in the storyboard itself.

2条回答
来,给爷笑一个
2楼-- · 2019-01-19 05:04

Just found an answer myself, it was because Size Classes were reset after I moved the project...

Greying out views is Xcode's standard behaviour when the views are only set for a specific size class which is currently not selected!

I had set the size classes for my UIViewController to Compact - Any, this is what it looks like in proper state:

enter image description here

The problem occurs when I change the size classes to another one (e.g. Any - Any):

enter image description here

查看更多
【Aperson】
3楼-- · 2019-01-19 05:19

This happened to me because I copy and pasted some of my views from nib into storybaord. Turning size classes off, and turning it back on fixed the issue. This can be done in File inspector, using a checkbox named Use Size Classes

查看更多
登录 后发表回答