我有一个基本视图控制器:
@interface NEViewControllerWithSidebarMenu : UIViewController <UITableViewDataSource, UITableViewDelegate>
{
UIView *viewWithContent;
UIView *sidebarView;
UITableView *sidebarTableView;
}
@property (nonatomic, retain) UIView *viewWithContent;
@property (nonatomic, retain) UIView *sidebarView;
@property (nonatomic, retain) UITableView *sidebarTableView;
-(void)menuButtonPressed:(id)sender;
-(void)loadSidebar;
@end
它的实施:
#import "NEViewControllerWithSidebarMenu.h"
@interface NEViewControllerWithSidebarMenu ()
@end
@implementation NEViewControllerWithSidebarMenu
@synthesize sidebarView, sidebarTableView;
@synthesize viewWithContent;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Actions
-(void)menuButtonPressed:(id)sender
{
... do some things here
}
-(void)loadSidebar
{
.....
UIButton *menuButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[menuButton setFrame:CGRectMake(0.0, 0.0, 80, 40)];
[menuButton setTitle:@"Меню" forState:UIControlStateNormal];
[menuButton addTarget:self action:@selector(menuButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *menuBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView:menuButton];
self.navigationItem.leftBarButtonItem=menuBarButtonItem;
.....
}
-(void)changeToViewController:(UIViewController *)viewController
{
UINavigationController *navController = self.navigationController;
[navController popViewControllerAnimated:NO];
[navController pushViewController:viewController animated:NO];
}
-(void)popViewControllerAnimated
{
[self.navigationController popViewControllerAnimated:YES];
}
-(void)pushViewControllerAnimated:(UIViewController *)viewController
{
[self.navigationController pushViewController:viewController animated:YES];
}
#pragma mark - UITableViewDataSourse
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
switch (section)
{
case 0:
{
return 6;
break;
}
default:
{
NSLog(@"PANIC: unknown section index");
return 13;
break;
}
};
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
......
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
.......
}
@end
现在我声明一个从NEViewControllerWithSidebarMenu继承的控制器我收到错误:
@interface NECompanyRootViewController : NEViewControllerWithSidebarMenu
{
//
}
@end
无法找到'NEViewControllerWithSidebarMenu'的接口声明,'NECompanyRootViewController
的超类请帮帮我。为什么我会收到此错误,如何解决?
答案 0 :(得分:2)
首先导入标题
#import "NEViewControllerWithSidebarMenu.h"
@interface NECompanyRootViewController : NEViewControllerWithSidebarMenu
{
//
}
@end