我有同样的问题,如此Link我有UIControl(名为GCDatePickerControl),我有另一个类(名为GCCalendarPortraitView) 在类GCCalendarPortraitView我有代码
dayPicker = [[GCDatePickerControl alloc] init];
dayPicker.frame = CGRectMake(0, 0, self.view.frame.size.width, 0);
dayPicker.autoresizingMask = UIViewAutoresizingNone;
dayPicker.date = date;
[dayPicker addTarget:self action:@selector(datePickerDidChangeDate:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:dayPicker];
其中dayPicker是GCDatePickerControl类的对象
在GCDatePickerControl中我有代码
[self sendActionsForControlEvents:UIControlEventValueChanged];
如果我评论以下任何一行,我的代码应用运行正常
[self sendActionsForControlEvents:UIControlEventValueChanged];
[dayPicker addTarget:self action:@selector(datePickerDidChangeDate:) forControlEvents:UIControlEventValueChanged];
但是如果我取消注释我的App粉碎节目在控制台上显示这个结果
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayerArray datePickerDidChangeDate:]: unrecognized selector sent to instance 0x7a2cc30'
*** Call stack at first throw:
(
0 CoreFoundation 0x02c86919 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x02dd45de objc_exception_throw + 47
2 CoreFoundation 0x02c8842b -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x02bf8116 ___forwarding___ + 966
4 CoreFoundation 0x02bf7cd2 _CF_forwarding_prep_0 + 50
5 UIKit 0x00303e14 -[UIApplication sendAction:to:from:forEvent:] + 119
6 UIKit 0x0038d6c8 -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x0038fb4a -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
8 UIKit 0x0038d67f -[UIControl sendActionsForControlEvents:] + 49
9 CalendarApp 0x00016d7f -[GCDatePickerControl buttonPressed:] + 437
10 UIKit 0x00303e14 -[UIApplication sendAction:to:from:forEvent:] + 119
11 UIKit 0x0038d6c8 -[UIControl sendAction:to:forEvent:] + 67
12 UIKit 0x0038fb4a -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
13 UIKit 0x0038e6f7 -[UIControl touchesEnded:withEvent:] + 458
14 UIKit 0x003272ff -[UIWindow _sendTouchesForEvent:] + 567
15 UIKit 0x003091ec -[UIApplication sendEvent:] + 447
16 UIKit 0x0030dac4 _UIApplicationHandleEvent + 7495
17 GraphicsServices 0x03413afa PurpleEventCallback + 1578
18 CoreFoundation 0x02c67dc4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
19 CoreFoundation 0x02bc8737 __CFRunLoopDoSource1 + 215
20 CoreFoundation 0x02bc59c3 __CFRunLoopRun + 979
21 CoreFoundation 0x02bc5280 CFRunLoopRunSpecific + 208
22 CoreFoundation 0x02bc51a1 CFRunLoopRunInMode + 97
23 GraphicsServices 0x034122c8 GSEventRunModal + 217
24 GraphicsServices 0x0341238d GSEventRun + 115
25 UIKit 0x00311b58 UIApplicationMain + 1160
26 CalendarApp 0x000025c4 main + 102
27 CalendarApp 0x00002555 start + 53
28 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
我无法追查我的问题PLZ任何人帮助我谢谢你
答案 0 :(得分:0)
当控件尝试调用给定目标上的选择器并且该命令不存在时,会发生此错误。在你的情况下,你检查过“datePickerDidChangeDate:”是否存在?这可能只是一个拼写错误。