1

这非常奇怪!它的东西很简单,这就是我无法理解的原因。下面是我的课。

#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 Headache 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];
}
4

2 回答 2

1

看起来像内存问题。如果你使用 ARC,你应该保持对视图控制器的强烈引用。如果您使用手动内存管理,可能视图控制器已被过度释放。要查找问题,您可以将 NSZombieEnabled 标志添加到方案或将 Instruments 与 Zombie 一起使用。

于 2013-10-28T11:55:10.477 回答
0

只是一个建议,但是您是否检查了 IB 中按钮的事件连接。愿您离开与另一个 VC 的连接,在该 VC 中您已删除操作方法。检查控制台 loginButtonPressed:]: unrecognized selector sent to instance 0x15e3bf60 what is 0x15e3bf60 (po 0x15e3bf60).

于 2013-10-28T15:02:07.120 回答