更新:现在一切正常,忘记链接 .xib 文件中的视图。
我已经像这样导入了我的视图控制器的实现文件;
#import "TopicsListParentViewController.h"
当我写:
TopicsListParentViewController *tlparentview;
一开始没有错误,但是在构建项目的时候,出现了这个错误:
未知类型名称“TopicsListParentViewController”;你的意思是“TopicsListViewController”吗?
为什么会这样,我该如何解决?这是一个屏幕截图,可帮助您更准确地想象场景:
编辑:这是“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