iPhone模拟器在设置自定义UIViewController类时显示黑屏

时间:2021-05-13 23:08:10

When creating a single view application in Xcode and dragging a UIButton in, for example, the button shows up when running the application in the iPhone simulator. However, when creating a new UIViewController class and setting that as the custom class of the view controller in the storyboard file, just a black screen is shown in the iPhone Simulator.

例如,在Xcode中创建一个视图应用程序并在其中拖拽一个UIButton时,该按钮在iPhone模拟器中运行应用程序时显示出来。然而,当创建一个新的UIViewController类并将其设置为故事板文件中视图控制器的自定义类时,iPhone模拟器中只显示了一个黑屏。

What did I do wrong?

我做错了什么?

1 个解决方案

#1


5  

I bet the Xcode template included the loadView method in your controller class. You need to delete that as you only override that method when you are creating your interface via code.

我打赌Xcode模板在控制器类中包含了loadView方法。您需要删除它,因为您仅在通过代码创建接口时重写该方法。

#1


5  

I bet the Xcode template included the loadView method in your controller class. You need to delete that as you only override that method when you are creating your interface via code.

我打赌Xcode模板在控制器类中包含了loadView方法。您需要删除它,因为您仅在通过代码创建接口时重写该方法。