.h实现文件无法识别我的UIViewController

时间:2012-04-27 06:16:37

标签: iphone objective-c ios xcode uiviewcontroller

更新:现在全部正常工作,忘记链接.xib文件中的视图。

我已经导入了我的视图控制器的实现文件;

#import "TopicsListParentViewController.h"

当我写:

TopicsListParentViewController *tlparentview;

首先没有错误,但在构建项目时,会出现此错误:

未知类型名称'TopicsListParentViewController';你的意思是'TopicsListViewController'吗?

为什么会这样,我该如何解决?这是一个截图,可以帮助您更准确地想象场景:

enter image description here

编辑:以下是“TopicsListParentViewController”的.h和.m

.h实施文件:

//
//  TopicsListParentViewController.h
//
//  Created by James Anderson on 27/04/2012.
//  Copyright (c) 2012 PixelBit Apps Ltd. All rights reserved.
//

#import "SuperChatAppDelegate.h"
#import "TopicsListViewController.h"

@interface TopicsListParentViewController : UIViewController {

IBOutlet UIView *parentview;

IBOutlet TopicsListViewController *topicsListViewController;

}

@end

.m实施文件:

//
//  TopicsListParentViewController.m
//
//  Created by James Anderson on 27/04/2012.
//  Copyright (c) 2012 PixelBit Apps Ltd. All rights reserved.
//

#import "TopicsListParentViewController.h"

@implementation TopicsListParentViewController 

-(void)viewDidLoad
{

[parentview addSubview:topicsListViewController.tableView];
NSLog(@"Added subview");

}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation ==     UIInterfaceOrientationLandscapeRight);
}

- (void)dealloc {
[super dealloc];
}

@end

3 个答案:

答案 0 :(得分:0)

仔细检查以确保您的文件正确。

 @interface TopicsListParentViewController
  ...
 @end

 @implementation TopicsListParentViewController
  ...
 @end

答案 1 :(得分:0)

检查endy的帖子+检查是否将TopicsListParentViewController放入项目的目标 - >意识到仅将文件添加到测试目标

答案 2 :(得分:0)

我猜你的Xcode派生数据目录已损坏。

删除它并尝试干净的构建。