UISearchBar ios 7在取消时崩溃

时间:2014-02-17 06:23:54

标签: ios iphone objective-c ios7

我正在使用UITableViewController,在表添加的搜索栏的标题视图中。在iOS 6中搜索和取消按钮对我来说很好,但在iOS 7搜索工作正常,当我点击取消按钮应用程序崩溃时,以下消息。

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UITableView's implementation of -layoutSubviews needs to call super.'
*** First throw call stack:
(
    0   CoreFoundation                      0x021f05e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x01f738b6 objc_exception_throw + 44
    2   CoreFoundation                      0x021f0448 +[NSException raise:format:arguments:] + 136
    3   Foundation                          0x01b53fee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
    4   UIKit                               0x00b1f33b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 567
    5   libobjc.A.dylib                     0x01f8581f -[NSObject performSelector:withObject:] + 70
    6   QuartzCore                          0x01a392ea -[CALayer layoutSublayers] + 148
    7   QuartzCore                          0x01a2d0d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    8   QuartzCore                          0x01a3b715 -[CALayer(CALayerPrivate) layoutBelowIfNeeded] + 43
    9   UIKit                               0x00b11c76 -[UIView(Hierarchy) layoutBelowIfNeeded] + 595
    10  UIKit                               0x00e4be70 -[UISearchDisplayController _hoistSearchBar] + 992
    11  UIKit                               0x00e4ccb2 -[UISearchDisplayController showHideAnimationDidFinish] + 108
    12  UIKit                               0x00b00c6c -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 267
    13  UIKit                               0x00b00f58 -[UIViewAnimationState animationDidStop:finished:] + 80
    14  QuartzCore                          0x01a34a44 _ZN2CA5Layer23run_animation_callbacksEPv + 304
    15  libdispatch.dylib                   0x0249f4b0 _dispatch_client_callout + 14
    16  libdispatch.dylib                   0x0248d75e _dispatch_main_queue_callback_4CF + 340
    17  CoreFoundation                      0x02255a5e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
    18  CoreFoundation                      0x021966bb __CFRunLoopRun + 1963
    19  CoreFoundation                      0x02195ac3 CFRunLoopRunSpecific + 467
    20  CoreFoundation                      0x021958db CFRunLoopRunInMode + 123
    21  GraphicsServices                    0x033df9e2 GSEventRunModal + 192
    22  GraphicsServices                    0x033df809 GSEventRun + 104
    23  UIKit                               0x00ab4d3b UIApplicationMain + 1225
    24  uAlign                              0x00001f6d main + 141
    25  libdyld.dylib                       0x0273170d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

我正在使用故事板和默认取消按钮。

请帮助解决这个问题。谢谢。

2 个答案:

答案 0 :(得分:0)

取消选中使用AutoLaout字段并尝试再次运行,请参见下图: enter image description here

答案 1 :(得分:0)

UITableView's implementation of -layoutSubviews needs to call super.

我认为这是问题。

检查所有UITableView的layoutSubviews实现,添加[super layoutSubviews];

- (void)layoutSubviews{
    [super layoutSubviews];
    //to do other things
}