【发布时间】:2013-10-28 11:35:44
【问题描述】:
这太奇怪了!它的东西很简单,这就是我无法理解的原因。下面显示了我的课程。
#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' * 首先抛出调用栈:
我已经检查过了,按钮正确地发送了“touch up inside to 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];
}
【问题讨论】:
-
你在使用 ARC 吗? .看看这个问题stackoverflow.com/questions/2455161/…
-
也可以在您的按钮上查看它是否仅连接到一个
IBAction。如果您更改了方法名称,它可能仍指向旧名称。 -
请展示您为 LogInViewController 声明对象的代码
-
我添加了上面的代码,显示我将笔尖附加到我的主视图控制器中的 uiview,谢谢
-
我已经检查过按钮肯定连接到正确的方法:)
标签: ios objective-c exception uibutton unrecognized-selector