gpt4 book ai didi

ios - UIViewController 中的 UISearchBar 崩溃

转载 作者:行者123 更新时间:2023-11-28 22:00:36 25 4
gpt4 key购买 nike

我在使用 UISearchBar 时发生了奇怪的崩溃。我在 Storyboard上有一个 View Controller ,一切正常,但是一旦在 View Controller 中拖动 UISearchBar 然后运行该应用程序,我就会遇到以下崩溃:

* thread #1: tid = 0x6d83b, 0x0462169e libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x0462169e libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x045ef2c5 libsystem_pthread.dylib`pthread_kill + 101
frame #2: 0x043609c9 libsystem_sim_c.dylib`abort + 127
frame #4: 0x03a1c35d CoreFoundation`__handleUncaughtException + 749
frame #5: 0x0370bb8b libobjc.A.dylib`_objc_terminate() + 100
frame #6: 0x03ee5f60 libc++abi.dylib`std::__terminate(void (*)()) + 14
frame #7: 0x03ee597d libc++abi.dylib`__cxa_throw + 116
frame #8: 0x0370b9fc libobjc.A.dylib`objc_exception_throw + 323
frame #9: 0x03a29243 CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:] + 275
frame #10: 0x0397c50b CoreFoundation`___forwarding___ + 1019
frame #11: 0x0397c0ee CoreFoundation`__forwarding_prep_0___ + 14
frame #12: 0x01fd0ba4 UIKit`-[UISearchBar(UISearchBarStatic) _updateMagnifyingGlassView] + 486
frame #13: 0x01fd0cdb UIKit`-[UISearchBar(UISearchBarStatic) _setupSearchField] + 210
frame #14: 0x01fc6af6 UIKit`-[UISearchBar initWithCoder:] + 1500
frame #15: 0x0210bd6d UIKit`UINibDecoderDecodeObjectForValue + 704
frame #16: 0x0210bf6e UIKit`UINibDecoderDecodeObjectForValue + 1217
frame #17: 0x0210baa1 UIKit`-[UINibDecoder decodeObjectForKey:] + 114
frame #18: 0x01d43fa4 UIKit`-[UIView initWithCoder:] + 842
frame #19: 0x0210bd6d UIKit`UINibDecoderDecodeObjectForValue + 704
frame #20: 0x0210baa1 UIKit`-[UINibDecoder decodeObjectForKey:] + 114
frame #21: 0x01fa67a7 UIKit`-[UIRuntimeConnection initWithCoder:] + 191
frame #22: 0x0210bd6d UIKit`UINibDecoderDecodeObjectForValue + 704
frame #23: 0x0210bf6e UIKit`UINibDecoderDecodeObjectForValue + 1217
frame #24: 0x0210baa1 UIKit`-[UINibDecoder decodeObjectForKey:] + 114
frame #25: 0x01fa5c21 UIKit`-[UINib instantiateWithOwner:options:] + 1117
frame #26: 0x01e0e6f5 UIKit`-[UIViewController _loadViewFromNibNamed:bundle:] + 280
frame #27: 0x01e0ee9d UIKit`-[UIViewController loadView] + 302
frame #28: 0x01e0f0d3 UIKit`-[UIViewController loadViewIfRequired] + 78
frame #29: 0x01e0f5d9 UIKit`-[UIViewController view] + 35
frame #30: 0x01e29942 UIKit`-[UINavigationController _startCustomTransition:] + 778
frame #31: 0x01e368f7 UIKit`-[UINavigationController _startDeferredTransitionIfNeeded:] + 688
frame #32: 0x01e374e9 UIKit`-[UINavigationController __viewWillLayoutSubviews] + 57
frame #33: 0x01f780d1 UIKit`-[UILayoutContainerView layoutSubviews] + 213
frame #34: 0x01d5f964 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
frame #35: 0x0371d82b libobjc.A.dylib`-[NSObject performSelector:withObject:] + 70
frame #36: 0x0068345a QuartzCore`-[CALayer layoutSublayers] + 148
frame #37: 0x00677244 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 380
frame #38: 0x006770b0 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 26
frame #39: 0x005dd7fa QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 294
frame #40: 0x005deb85 QuartzCore`CA::Transaction::commit() + 393
frame #41: 0x005df258 QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92
frame #42: 0x0395436e CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
frame #43: 0x039542bf CoreFoundation`__CFRunLoopDoObservers + 399
frame #44: 0x03932254 CoreFoundation`__CFRunLoopRun + 1076
frame #45: 0x039319d3 CoreFoundation`CFRunLoopRunSpecific + 467
frame #46: 0x039317eb CoreFoundation`CFRunLoopRunInMode + 123
frame #47: 0x048dd5ee GraphicsServices`GSEventRunModal + 192
frame #48: 0x048dd42b GraphicsServices`GSEventRun + 104
frame #49: 0x01cf0f9b UIKit`UIApplicationMain + 1225
* frame #50: 0x00008f2d `main(argc=1, argv=0xbfffed90) + 141 at main.m:16

我不知道这里发生了什么。我所做的只是在 Storyboard中的主视图和 View Controller 中拖动一个 UISearchBar。没有搜索栏,一切正常,但是当我添加搜索栏并运行应用程序时。当我到达 View Controller 时,我遇到了这个崩溃。奇怪的是,控件甚至没有转到 View Controller 的 viewDidLoad。以前有其他人遇到过这个问题吗?我该怎么办?

更新

正确的崩溃轨迹:

2014-08-09 10:07:39.518 MyWorkflowww[20945:607] -[UIView setImage:]: unrecognized selector sent to instance 0xcf04830
2014-08-09 10:07:39.522 MyWorkflowww[20945:607] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setImage:]: unrecognized selector sent to instance 0xcf04830'
*** First throw call stack:
(
0 CoreFoundation 0x039891e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x037088e5 objc_exception_throw + 44
2 CoreFoundation 0x03a26243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0397950b ___forwarding___ + 1019
4 CoreFoundation 0x039790ee _CF_forwarding_prep_0 + 14
5 UIKit 0x01fcdba4 -[UISearchBar(UISearchBarStatic) _updateMagnifyingGlassView] + 486
6 UIKit 0x01fcdcdb -[UISearchBar(UISearchBarStatic) _setupSearchField] + 210
7 UIKit 0x01fc3af6 -[UISearchBar initWithCoder:] + 1500
8 UIKit 0x02108d6d UINibDecoderDecodeObjectForValue + 704
9 UIKit 0x02108f6e UINibDecoderDecodeObjectForValue + 1217
10 UIKit 0x02108aa1 -[UINibDecoder decodeObjectForKey:] + 114
11 UIKit 0x01d40fa4 -[UIView initWithCoder:] + 842
12 UIKit 0x02108d6d UINibDecoderDecodeObjectForValue + 704
13 UIKit 0x02108aa1 -[UINibDecoder decodeObjectForKey:] + 114
14 UIKit 0x01fa37a7 -[UIRuntimeConnection initWithCoder:] + 191
15 UIKit 0x02108d6d UINibDecoderDecodeObjectForValue + 704
16 UIKit 0x02108f6e UINibDecoderDecodeObjectForValue + 1217
17 UIKit 0x02108aa1 -[UINibDecoder decodeObjectForKey:] + 114
18 UIKit 0x01fa2c21 -[UINib instantiateWithOwner:options:] + 1117
19 UIKit 0x01e0b6f5 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
20 UIKit 0x01e0be9d -[UIViewController loadView] + 302
21 UIKit 0x01e0c0d3 -[UIViewController loadViewIfRequired] + 78
22 UIKit 0x01e0c5d9 -[UIViewController view] + 35
23 UIKit 0x01d2c267 -[UIWindow addRootViewControllerViewIfPossible] + 66
24 UIKit 0x01d2c5ef -[UIWindow _setHidden:forced:] + 312
25 UIKit 0x01d2c86b -[UIWindow _orderFrontWithoutMakingKey] + 49
26 UIKit 0x01d373c8 -[UIWindow makeKeyAndVisible] + 65
27 MyWorkflowww 0x000091c2 -[MyAppDelegate application:didFinishLaunchingWithOptions:] + 610
28 UIKit 0x01ce714f -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
29 UIKit 0x01ce7aa1 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1810
30 UIKit 0x01cec667 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
31 UIKit 0x01d00f92 -[UIApplication handleEvent:withNewEvent:] + 3517
32 UIKit 0x01d01555 -[UIApplication sendEvent:] + 85
33 UIKit 0x01cee250 _UIApplicationHandleEvent + 683
34 GraphicsServices 0x048dbf02 _PurpleEventCallback + 776
35 GraphicsServices 0x048dba0d PurpleEventCallback + 46
36 CoreFoundation 0x03904ca5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
37 CoreFoundation 0x039049db __CFRunLoopDoSource1 + 523
38 CoreFoundation 0x0392f68c __CFRunLoopRun + 2156
39 CoreFoundation 0x0392e9d3 CFRunLoopRunSpecific + 467
40 CoreFoundation 0x0392e7eb CFRunLoopRunInMode + 123
41 UIKit 0x01cebd9c -[UIApplication _run] + 840
42 UIKit 0x01cedf9b UIApplicationMain + 1225
43 0x00008f2d main + 141
44 libdyld.dylib 0x044f36d9 start + 1
45 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

最佳答案

发现问题,显然我使用的是将 leftView 设置为 UIView 的外观方法。当 UISearchBar 中的 UITextField 将放大镜图像设置为 UITextField 的左 View (这是一个 UIView)时,这就是它崩溃的原因。修复它。

关于ios - UIViewController 中的 UISearchBar 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25214509/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com