Xcode 中发生了最奇怪的事情。我有一个名为 SettingsViewController 的 View Controller 文件。从 SettingsViewController,我试图插入 GameViewController。当我制作这个文件时,我错误地将它命名为 ViewViewController 而不是 GameViewController(来晚了 :D)。我在 Storyboard 文件的标识选项卡中设置了文件各自 View 的类。后来,我尝试通过在左列中右键单击它并单击重命名来将文件 ViewViewController 的名称更改为 GameViewController。我进入 Storyboard文件,更改了游戏 View 的类。现在,我可以通过说 将 GameViewController 文件导入到 SettingsViewController 文件中
#import GameViewController.h
但是下一行给出了一个错误:
GameViewController *gvc = [[GameViewController alloc] init];
错误提示 unknown type name GameViewController: Did you mean ViewViewController?
我是否遗漏了需要进行的更改?我所做的只是更改文件名并更改 Storyboard中的类。
最佳答案
当我正要发布这个问题时,我意识到了答案。我必须进入 GameViewController.h 并更改行
@interface ViewViewController : UIViewController
到
@interface GameViewController : UIViewController
然后,在 GameViewController.m 中,我必须更改:
@interface ViewViewController ()
到
@interface GameViewController ()
和改变
@implementation ViewViewController
到
@implementation GameViewController
关于ios - 卡在 Xcode 中的文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21436020/