UIView崩溃发送IBAction时

时间:2014-05-23 21:02:24

标签: ios objective-c uiview ibaction

我最近开始使用MVC架构设置我的应用程序。我有一个GetStartedView类,带有相应的xib文件,如下所示。我还有一个加载视图的GetStartedViewController。我遇到的问题是每当我点击一个按钮时,应用程序崩溃。我知道发生了什么,但我完全迷失了如何修复它。我加载笔尖错了吗?非常感谢任何建议和帮助。

http://i.imgur.com/pRRp4h1.png

#import "GetStartedView.h"

@implementation GetStartedView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"GetStartedView" owner:self options:nil];
        // assuming the view is the only top-level object in the nib file (besides File's Owner and First Responder)

        UIView *nibView = [nibObjects objectAtIndex:0];
        [self addSubview:nibView];
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

- (IBAction)signupButtonTouched:(id)sender {
    NSLog(@"hello");
}

- (IBAction)signinButtonTouched:(id)sender {
}

- (IBAction)facebookButtonTouched:(id)sender {
}

- (IBAction)twitterButtonTouched:(id)sender {
}
@end


@interface GetStartedViewController ()

@end

@implementation GetStartedViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    GetStartedView *gsView = [[GetStartedView alloc] initWithFrame:self.view.frame];
    [self.view addSubview:gsView];

    //[self.view bringSubviewToFront:nibView];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end

以下是崩溃日志:

2014-05-23 16:49:34.126 App[1364:90b] -[NSISEngine twitterButtonTouched:]: unrecognized selector sent to instance 0x10cc73580
2014-05-23 16:49:34.131 App[1364:90b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSISEngine twitterButtonTouched:]: unrecognized selector sent to instance 0x10cc73580'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010444b495 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000103ff499e objc_exception_throw + 43
    2   CoreFoundation                      0x00000001044dc65d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x000000010443cd8d ___forwarding___ + 973
    4   CoreFoundation                      0x000000010443c938 _CF_forwarding_prep_0 + 120
    5   UIKit                               0x0000000102ea0f06 -[UIApplication sendAction:to:from:forEvent:] + 80
    6   UIKit                               0x0000000102ea0eb4 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 17
    7   UIKit                               0x0000000102f7d880 -[UIControl _sendActionsForEvents:withEvent:] + 203
    8   UIKit                               0x0000000102f7cdc0 -[UIControl touchesEnded:withEvent:] + 530
    9   UIKit                               0x0000000102ed7d05 -[UIWindow _sendTouchesForEvent:] + 701
    10  UIKit                               0x0000000102ed86e4 -[UIWindow sendEvent:] + 925
    11  UIKit                               0x0000000102eb029a -[UIApplication sendEvent:] + 211
    12  UIKit                               0x0000000102e9daed _UIApplicationHandleEventQueue + 9579
    13  CoreFoundation                      0x00000001043dad21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    14  CoreFoundation                      0x00000001043da5f2 __CFRunLoopDoSources0 + 242
    15  CoreFoundation                      0x00000001043f646f __CFRunLoopRun + 767
    16  CoreFoundation                      0x00000001043f5d83 CFRunLoopRunSpecific + 467
    17  GraphicsServices                    0x0000000105541f04 GSEventRunModal + 161
    18  UIKit                               0x0000000102e9fe33 UIApplicationMain + 1010
    19  App                                 0x0000000100003783 main + 115
    20  libdyld.dylib                       0x0000000104a077e1 start + 0
    21  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

0 个答案:

没有答案