Я использую раскадровки Xcode и имею контроллер View с UITableView, который, в свою очередь, имеет пользовательский UITableViewCell.Xcode Storyboard - UITableViewCell Значение UISwitch изменено
UITableViewCell имеет UISwitch, и я хочу знать, когда значение изменилось. У меня есть IBAction, успешно срабатывает, если значение изменяется
- (IBAction)updateSwitchAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"In SettingsViewcontroller updateSwitchAtIndexPath row=|%d \n", indexPath.row);
}
Однако, когда он запускает приложение завершает
2014-07-10 23:38:10.037 reactor[2572:60b] -[UISwitch row]: unrecognized selector sent to instance 0x944b7e0
2014-07-10 23:38:10.072 reactor[2572:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UISwitch row]: unrecognized selector sent to instance 0x944b7e0'
*** First throw call stack:
(
0 CoreFoundation 0x01a281e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x015758e5 objc_exception_throw + 44
2 CoreFoundation 0x01ac5243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01a1850b ___forwarding___ + 1019
4 CoreFoundation 0x01a180ee _CF_forwarding_prep_0 + 14
5 positivity 0x00003807 -[SettingsViewController updateSwitchAtIndexPath:] + 87
6 libobjc.A.dylib 0x0158782b -[NSObject performSelector:withObject:] + 70
7 UIKit 0x002373b9 -[UIApplication sendAction:to:from:forEvent:] + 108
8 UIKit 0x00237345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
9 UIKit 0x00338bd1 -[UIControl sendAction:to:forEvent:] + 66
10 UIKit 0x00338fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
11 UIKit 0x004c97a5 __31-[UISwitch _handleLongPressNL:]_block_invoke + 85
12 UIKit 0x004c8666 -[_UISwitchInternalViewNeueStyle1 _setPressed:on:animated:shouldAnimateLabels:completion:] + 243
13 UIKit 0x004c9681 -[UISwitch _handleLongPressNL:] + 286
14 UIKit 0x005d14f4 _UIGestureRecognizerSendActions + 230
15 UIKit 0x005d0168 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 383
16 UIKit 0x005d1bdd -[UIGestureRecognizer _delayedUpdateGesture] + 60
17 UIKit 0x005d513d ___UIGestureRecognizerUpdate_block_invoke + 57
18 UIKit 0x005d50be _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 317
19 UIKit 0x005cb7ac _UIGestureRecognizerUpdate + 199
20 UIKit 0x00276a5a -[UIWindow _sendGesturesForEvent:] + 1291
21 UIKit 0x00277971 -[UIWindow sendEvent:] + 1021
22 UIKit 0x002495f2 -[UIApplication sendEvent:] + 242
23 UIKit 0x00233353 _UIApplicationHandleEventQueue + 11455
24 CoreFoundation 0x019b177f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
25 CoreFoundation 0x019b110b __CFRunLoopDoSources0 + 235
26 CoreFoundation 0x019ce1ae __CFRunLoopRun + 910
27 CoreFoundation 0x019cd9d3 CFRunLoopRunSpecific + 467
28 CoreFoundation 0x019cd7eb CFRunLoopRunInMode + 123
29 GraphicsServices 0x03a1c5ee GSEventRunModal + 192
30 GraphicsServices 0x03a1c42b GSEventRun + 104
31 UIKit 0x00235f9b UIApplicationMain + 1225
32 positivity 0x00005dbd main + 141
33 libdyld.dylib 0x0206f701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Любая помощь будет принята с благодарностью
Спасибо за быстрый ответ, но как я могу сказать, какая строка была выбрана? –
Технически вы не выбрали строку. Почему вы хотите узнать, какая строка была выбрана? Вы уже знаете, какая ячейка содержит UISwitch. – joelg
Как мне это узнать? У каждой строки есть uiswitch. –