开发者

This class is not key value coding-compliant for the key navItem

I am working on my first iOS app. Now, i am trying to link UINavigationItem to *navItem. But when i have done this, i get the error: This class is not key value coding-compliant for the key navItem.

I googled this error, and find out that this error is generally caused by one or two problems. The first is that the @synthesize was forgotten. The second was that the class of the File Owner is not set correctly.

But that is not the solution of my problem, because these 2 seems to by correct in my code. I debuged for over a half day, but never found the solution.

This is my code:

The TestTab.h file

#import <UIKit/UIKit.h>


@interface TestTab : UIViewController {
    IBOutlet UINavigationItem *navItem;
}
@property (nonatomic, retain) UINavigationItem *navItem;

@end

The TestTab.m file:

#import "TestTab.h"


@implementation TestTab
@synthesize navItem;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    retu开发者_JAVA百科rn self;
}

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

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

This class is not key value coding-compliant for the key navItem

This class is not key value coding-compliant for the key navItem

Can someone see what the problem is?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜