You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iOS Storyboard中ViewController变灰空白问题求助

Fixing Grayed-Out ViewController in Storyboard

Hey there! Sorry to hear you're stuck with this frustrating issue—let's break down some simple, beginner-friendly steps to get your ViewController back to normal in Storyboard.

Common Fixes to Try:

  • Double-check the Custom Class association
    Click on the grayed-out ViewController, then open the Identity Inspector (the third icon in the right sidebar, looks like a name tag). Under the "Custom Class" section:

    • Make sure the Class dropdown is set to your actual ViewController class (not empty or the wrong one).
    • Ensure the Module field is automatically populated with your project name (don't leave it as "None"). If it's empty, select your project from the dropdown.
  • Verify Storyboard Target Membership
    In the Project Navigator (left sidebar), select your Storyboard file. Open the File Inspector (first icon in the right sidebar). Look for the "Target Membership" section and make sure your main project target is checked. If it's unchecked, tick it and rebuild.

  • Check your ViewController file's Target Membership
    Go to your ViewController.swift file, open the File Inspector the same way, and confirm the project target is checked here too. Sometimes files accidentally get removed from the target, which breaks the Storyboard link.

  • Reset the Custom Class association
    If the class looks correct but the VC is still gray:

    1. Delete the class name from the "Custom Class" field in Identity Inspector and press Enter.
    2. Wait a second, then re-select your ViewController class from the dropdown. This often fixes hidden linking issues.
  • Clear Xcode's deeper caches
    You already tried deleting Derived Data, but let's try clearing Xcode's main cache:

    1. Quit Xcode completely.
    2. Open Terminal and run this command:
      rm -rf ~/Library/Caches/com.apple.dt.Xcode
    3. Restart Xcode and open your project again.
  • Test with a fresh Storyboard copy
    If all else fails, try creating a new Storyboard file (File > New > File > Storyboard), drag a new ViewController into it, and link it to your class. If this new VC shows up normally, it might mean your original Storyboard is slightly corrupted. You can then copy your other ViewControllers to the new file and replace the old one.

If you're still stuck:

Feel free to share a bit more detail—like whether this started happening after renaming a class, or if you made any changes to your project targets recently. That can help narrow things down further!

内容的提问来源于stack exchange,提问作者Misho Milicevic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:26:11