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

标签 iphone objective-c ios xcode uiviewcontroller

更新:现在一切正常,忘记链接 .xib 文件中的 View 。

我已经像这样导入了我的 View Controller 的实现文件;

#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

最佳答案

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

 @interface TopicsListParentViewController
  ...
 @end

 @implementation TopicsListParentViewController
  ...
 @end

关于iphone - .h 实现文件无法识别我的 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10345667/

相关文章:

ios - UICollectionViewLayout(从 Swift 转换为 Objective-C)

iphone - 将应用程序提交到应用商店时,如何分配多个开发人员?

ios - 使用默认摄像头启用视频模式

ios - 如果表未重新加载,则将带有标识符的数据传递到目标 UITableViewCell 将返回 nil?

iphone - 知道为什么这个图像屏蔽代码不起作用吗?

ios - 使用 UIRefresh 更新 TableView

c - 让 Xcode 告诉编译器不要链接到任何库,包括标准库?

iphone - 捏缩放在 ios7 中的多图像 UIScrollview 中不起作用

直接从 appDelegate 切换选项卡时 iOS NSURLConnection 失败

ios - 如何从NSArray中删除括号和?