UIControl sub Class problem in sendActionsForControlEvents
I have the same problem as mention in this Link I have UIControl (named GCDatePickerControl) and i have another Class (named GCCalendarPortraitView) In the Class GCCalendarPortraitView i have code
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];
where dayPicker is the object of GCDatePickerControl class
in the GCDatePickerControl i have code
[self sendActionsForControlEvents:UIControlEventValueChanged];
if i comment any of the below line my code app runs fine
[self sendActionsForControlEvents:UIControlEventValueChanged];
[dayPicker addTarget:self action:@selector(datePickerDidChangeDate:) forControlEvents:UIControlEventValueChanged];
but if i uncomment both the line my App crush show show me this result on console
*** 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'
i am unable to trace out my problem plz any one help me Thank You
This error occurs when the control try to call the selector on the given target and that's doesn't exist. In your case have you checked that "datePickerDidChangeDate:" exists? It may be just a typo error.
精彩评论