我正在開發一個應用程序。 我用TabBar和每個選項卡有它的類(FirstViewController,SecondViewController,...) 也有一個AppDelegate。Iphone:無法識別的選擇器發送到實例&viewDidLoad沒有運行
當我啓動程序時,第一個類正在運行。 當我選擇第二個選項卡時,Secondview
.xib正在運行,但「viewDidLoad
」不起作用。 當我選擇第三個選項卡時,情況相同。
我已經把一些按鈕第三個選項卡上,當我推,我有一個
> -[UIViewController testAuthentication:]: unrecognized selector sent to instance 0x5f16920
2011-04-08 13:46:42.511 e-mars[19501:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController testAuthentication:]: unrecognized selector sent to instance 0x5f16920'
這裏是我的班
的代碼SecondViewController.h
#import <UIKit/UIKit.h>
@interface SecondViewController : UIViewController {
}
@end
SecondViewController.m
#import "SecondViewController.h"
@implementation SecondViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"viewDidLoad de SecondViewController");
NSURL *url = [NSURL URLWithString: @"http://iosdevelopertips.com/images/logo-iphone-dev-tips.png"];
UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];
[self.view addSubview:[[UIImageView alloc] initWithImage:image]];
}
- (void)dealloc {
[super dealloc];
}
@end
ThirdViewController.h
#import <UIKit/UIKit.h>
@interface ThirdViewController : UIViewController {
IBOutlet UITextField *login;
IBOutlet UITextField *motdepasse;
NSMutableData *responseData;
}
@property (retain, nonatomic) UITextField *login;
@property (retain, nonatomic) UITextField *motdepasse;
@property (retain, nonatomic) NSMutableData *responseData;
- (IBAction) testAuthentication: (id)sender;
- (IBAction) saveAuthentication: (id)sender;
@end
ThirdViewController.m
#import "ThirdViewController.h"
@implementation ThirdViewController
@synthesize login;
@synthesize motdepasse;
@synthesize responseData;
- (id)initWithFrame:(CGRect)frame {
//if ((self = [super initWithFrame:frame])) {
// Initialization code
//}
return self;
}
-(IBAction) testAuthentication: (id)sender {
//NSLog(@"testAuthentication");
}
- (IBAction) saveAuthentication: (id)sender {
NSLog(@"saveAuthentication");
}
- (void)dealloc {
[login dealloc];
[motdepasse dealloc];
[responseData dealloc];
[super dealloc];
}
@end
我們需要查看您稱之爲「testauthentication」的代碼,以便有機會查看問題出在哪裏。 – scalbatty 2011-04-08 12:10:08
NSLog(@「testAuthentication」);是當前方法中的唯一代碼(並且不運行...確實) – clement 2011-04-08 14:07:03