UIAlertAction 意外触发 SearchBar TextDidBeginEditing

UIAlertAction Triggers SearchBar TextDidBeginEditing Unexpectedly

UIActionController 的呈现似乎以某种方式调用了我的搜索栏文本字段 textDidBeginEditing 方法。控制器最初是在搜索栏退出第一响应者之后立即显示的。这是 UIActionController 的预期行为吗?是否意味着在关闭后重新激活先前处于活动状态的搜索栏?

任何帮助都会很棒!

编辑:

我在搜索栏 didBeginEditing 方法上设置了一个断点,然后进行回溯以尝试查看谁在调用该方法(不确定这是否是他的正确方法)。这就是我得到的...这有什么帮助吗...有什么想法吗?

frame #1: 0x0000000189a9f4cc UIKit`-[UISearchBar(UISearchBarStatic) _searchFieldBeginEditing] + 84
frame #2: 0x00000001898dd398 UIKit`-[UIApplication sendAction:to:from:forEvent:] + 96
frame #3: 0x00000001898c6474 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 612
frame #4: 0x00000001898c5824 UIKit`-[UITextField willAttachFieldEditor:] + 764
frame #5: 0x00000001898c21c4 UIKit`-[UIFieldEditor becomeFieldEditorForView:] + 884
frame #6: 0x00000001899ab200 UIKit`-[UITextField _becomeFirstResponder] + 168
frame #7: 0x0000000189a9f300 UIKit`-[UISearchBarTextField _becomeFirstResponder] + 108
frame #8: 0x0000000189aa1f88 UIKit`-[UITextField __resumeBecomeFirstResponder] + 68
frame #9: 0x0000000189af6ad4 UIKit`__45-[UISearchBarTextField _becomeFirstResponder]_block_invoke + 316
frame #10: 0x0000000189a9f474 UIKit`-[UISearchBarTextField _becomeFirstResponder] + 480
frame #11: 0x000000018992ad28 UIKit`-[UIResponder becomeFirstResponder] + 392
frame #12: 0x000000018992b0ac UIKit`-[UIView(Hierarchy) becomeFirstResponder] + 124
frame #13: 0x00000001899a9de4 UIKit`-[UITextField becomeFirstResponder] + 68
frame #14: 0x0000000189988698 UIKit`-[UIPeripheralHost(UIKitInternal) _restoreInputViewsWithId:animated:] + 356
frame #15: 0x0000000189bcd9c8 UIKit`-[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:] + 1020
frame #16: 0x00000001899d02f8 UIKit`-[UIViewController _dismissViewControllerWithTransition:from:completion:] + 852
frame #17: 0x0000000189978388 UIKit`-[UIViewController dismissViewControllerWithTransition:completion:] + 1036
frame #18: 0x0000000189977f1c UIKit`-[UIViewController dismissViewControllerAnimated:completion:] + 252
frame #19: 0x0000000189c86f24 UIKit`-[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:] + 420
frame #20: 0x000000018989bf54 UIKit`_UIGestureRecognizerUpdate + 8536
frame #21: 0x0000000184de82a4 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
frame #22: 0x0000000184de5230 CoreFoundation`__CFRunLoopDoObservers + 360
frame #23: 0x0000000184de5610 CoreFoundation`__CFRunLoopRun + 836
frame #24: 0x0000000184d112d4 CoreFoundation`CFRunLoopRunSpecific + 396
frame #25: 0x000000018e7676fc GraphicsServices`GSEventRunModal + 168
frame #26: 0x000000018990ef40 UIKit`UIApplicationMain + 1488
frame #27: 0x00000001000ce974 Squirrel`main(argc=1, argv=0x000000016fd539d0) + 124 at main.m:14
frame #28: 0x00000001971a6a08 libdyld.dylib`start + 4

这解决了问题。

[[NSOperationQueue mainQueue]addOperationWithBlock:^{
    [self presentViewController:alert animated:YES completion:nil];
}];