Iphone UINavigationController错误使我的应用程序崩溃

Iphone UINavigationController错误使我的应用程序崩溃,iphone,ios,uinavigationcontroller,Iphone,Ios,Uinavigationcontroller,我正在尝试我的第一个UINavigationController应用程序,它现在正在崩溃。如果我注释掉以navController开头的行,我不会崩溃,但如果应用程序也不能工作 (注意:我的环境是IOS 4.2和Xcode 3.2) 这是坠机信息。有人能给我指出正确的方向吗?谢谢你的帮助。 在我的WpglViewController.h文件中,我声明了以下内容: @interface WpglViewController : NSObject <UIApplicationDelegate

我正在尝试我的第一个UINavigationController应用程序,它现在正在崩溃。如果我注释掉以navController开头的行,我不会崩溃,但如果应用程序也不能工作

(注意:我的环境是IOS 4.2和Xcode 3.2)

这是坠机信息。有人能给我指出正确的方向吗?谢谢你的帮助。

在我的WpglViewController.h文件中,我声明了以下内容:

@interface WpglViewController : NSObject <UIApplicationDelegate>

{
    UILabel *servingsLabel;
    UILabel *quantityLabel;
    UINavigationController *navigationController;
}

@property (nonatomic, retain) IBOutlet UILabel *servingsLabel;
@property (nonatomic, retain) IBOutlet UILabel *quantityLabel;
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) UINavigationController *navigationController;

@end
#import "WpglViewController.h"

@implementation WpglViewController

@synthesize servingsLabel;
@synthesize quantityLabel;
@synthesize navigationController;

要么没有像WpglViewController这样的类,要么您没有导入它,要么很可能您没有使用nib名称初始化它。WpglViewController是一个类,您必须在另一个类WpglViewController*firstViewController=[[WpglViewController alloc]initWithNibName:@“WpglViewController nib名称,可能是WpglViewController,除非您更改它,否则不要放置eh.xib扩展名”]

WpglViewController需要是UIViewController的子类

2011-09-04 07:59:49.309 wpgl[7302:207] -[WpglViewController title]: unrecognized selector sent to instance 0x4b134c0
异常表示WpglViewController不响应UIViewController中期望的title方法

2011-09-04 07:59:49.309 wpgl[7302:207] -[WpglViewController title]: unrecognized selector sent to instance 0x4b134c0

此消息说明了一切:您的WpglViewController没有实现方法“title”,可能您忘记了在.m文件中@synthesis属性?

检查
[WpglViewController title]
显然问题就在这里,可能您正在同一类的
init
中调用此方法。

请确保您的
WpglViewController
继承自
UIViewController

程序,我更新了此程序开头的信息以显示我的声明。如果我遗漏了什么,请告诉我。您的视图控制器不是视图控制器。它需要是UIViewController的子类,您可以将其作为NSObject的子类。是的,我已经解决了这个问题,但始终无法找到问题,因此我启动了一个新项目,它现在似乎工作正常。我不知道是什么东西被破坏了,也不知道在哪里。谢谢你的帮助。:)
2011-09-04 07:59:49.309 wpgl[7302:207] -[WpglViewController title]: unrecognized selector sent to instance 0x4b134c0