这太奇怪了!它简单的东西,这就是为什么我无法理解。下面显示了我的课程。
#import <UIKit/UIKit.h>
@interface LogInViewController : UIViewController
- (IBAction)loginButtonPressed:(id)sender;
@end
#import "LogInViewController.h"
@interface LogInViewController ()
@end
@implementation LogInViewController
- (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.
}
//
- (IBAction)loginButtonPressed:(id)sender
{
NSLog(@"login Button Pressed");
}
每当我点击按钮,它会抛出这个?!
loginButtonPressed:]:发送到实例的无法识别的选择器 0x15e3bf60 2013-10-28 11:23:24.249头痛Mbl [1352:60b] * 由于未捕获的异常而终止应用程序 'NSInvalidArgumentException',原因:' - [__ NSSetM loginButtonPressed:]:发送到实例的无法识别的选择器 0x15e3bf60' * 首先抛出调用堆栈:
我已经检查过了,按钮正确地发送了“内部触摸到loginButtonPressed:”
帮助!,谢谢你:)
以下是我将视图控制器附加到主屏幕的方法
@interface ViewController : UIViewController
@property (strong) IBOutlet UIView *loginView;
- (void)viewDidLoad
{
LogInViewController *logIn = [[LogInViewController alloc] initWithNibName:@"LogInViewController" bundle:nil];
[self.loginView addSubview:logIn.view];
[self.loginView setClipsToBounds:YES];
}
答案 0 :(得分:1)
看起来像是内存问题。如果您使用ARC,则应该对视图控制器进行强有力的参考。如果您使用手动内存管理可能视图控制器已被过度释放。要查找问题,您可以将NSZombieEnabled标志添加到方案或使用带僵尸的仪器。
答案 1 :(得分:0)
只是提案,但您是否检查了IB中按钮的事件连接。您是否可以将其连接到已删除操作方法的另一个VC。检查控制台 loginButtonPressed:]:无法识别的选择器发送到实例0x15e3bf60 什么是0x15e3bf60(po 0x15e3bf60)。