resignFirstResponder在自定义UlTableViewCell中使用UITextField时崩溃

时间:2013-01-14 23:41:34

标签: uitableview ios6 crash uitextfield uitextfielddelegate

我的应用程序出现间歇性崩溃。崩溃日志让我觉得UITextField的resignFirstResponser被调用的方式似乎有些问题。我在自定义tableview单元格中使用UITextField和UITextFieldDelegate协议方法,导致间歇性崩溃。我发布了下面的崩溃日志。请帮助我了解崩溃根本原因的任何建议或意见都会很棒。此外,似乎崩溃主要发生在iOS 6上

感谢。

以下是Crittercism崩溃日志:


    0   libobjc.A.dylib 0x39d585b0 objc_msgSend + 16 + 15
    1   UIKit 0x3477f165 -[UITextField _resignFirstResponder] + 457 + 456
    2   UIKit 0x34664249 -[UIResponder resignFirstResponder] + 281 + 280
    3   UIKit 0x34712397 -[UITextField resignFirstResponder] + 147 + 146
    4   UIKit 0x346962f5 -[UITableView reloadData] + 225 + 224
    5   BF 0x0008ed37 -[BFOpenBetsController updateFilterData] (BFOpenBetsController.m:768)
    6   BF 0x0008d695 -[BFOpenBetsController deleteBet:] (BFOpenBetsController.m:566)
    7   BF 0x00094fbd -[BFOpenBetsUnMatchedCell userTapOnButton:] (BFOpenBetsUnMatchedCell.m:198)
    8   UIKit 0x347380a5 -[UIApplication sendAction:to:from:forEvent:] + 73 + 72
    9   UIKit 0x34738057 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 31 + 30
    10  UIKit 0x34738035 -[UIControl sendAction:to:forEvent:] + 45 + 44
    11  UIKit 0x347378eb -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 503 + 502
    12  UIKit 0x34737de1 -[UIControl touchesEnded:withEvent:] + 489 + 488
    13  UIKit 0x34656421 _UIGestureRecognizerUpdate + 5769 + 5768
    14  CoreFoundation 0x351536cd __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 21 + 20
    15  CoreFoundation 0x351519c1 __CFRunLoopDoObservers + 277 + 276
    16  CoreFoundation 0x35151d17 __CFRunLoopRun + 743 + 742
    17  CoreFoundation 0x350c4ebd CFRunLoopRunSpecific + 357 + 356
    18  CoreFoundation 0x350c4d49 CFRunLoopRunInMode + 105 + 104
    19  GraphicsServices 0x32a172eb GSEventRunModal + 75 + 74
    20  UIKit 0x346a12f9 UIApplicationMain + 1121 + 1120

2 个答案:

答案 0 :(得分:0)

似乎在更新过滤器数据时,您会重新加载tableview,并且某些UITextField处于编辑模式。 尝试用这样的东西重现。

如果出现此问题,请在resignFirstResponder上致电UITextField之前,在所有有效reloadData上尝试UITableView

答案 1 :(得分:0)

可能会释放一个UITextField(就像滚动视图外,或者重新加载视图时一样)。看到你有一个TextField委托,它很可能不知道该字段不再存在,所以当它调用resign first responder时,它会崩溃。

解决方案是在自定义单元格的dealloc例程中调用uitextfield setDelegate:nil。

请参阅https://stackoverflow.com/a/9484805/899996

相关问题