I have a UIViewController
, which add a UITableView
, a UISearchController
. I present this ViewController
as UIModalPresentationPopover
style.If i only dismiss the ViewController
, that's no problem.But when searching text and keyboard showed, then dismiss the ViewController
, it crashed! It don't crash when i tap the area outside the popover view.
[Self dismissViewControllerAnimated:YES completion:nil];//dismiss
it'll crash when dismiss like this pic below. enter image description here enter image description here
Thread 1 > 19 UIApplicationMain
UIKit`UIApplicationMain:
0x11119d549 <+0>: pushq %rbp
0x11119d54a <+1>: movq %rsp, %rbp
0x11119d54d <+4>: pushq %r15
0x11119d54f <+6>: pushq %r14
0x11119d551 <+8>: pushq %r13
0x11119d553 <+10>: pushq %r12
0x11119d555 <+12>: pushq %rbx
0x11119d556 <+13>: pushq %rax
0x11119d557 <+14>: movq %rcx, %rbx
0x11119d55a <+17>: movq %rsi, -0x30(%rbp)
0x11119d55e <+21>: movl %edi, %r12d
0x11119d561 <+24>: movq 0x115d090(%rip), %r13 ; (void *)0x0000000114a1dc50: objc_retain
0x11119d568 <+31>: movq %rdx, %rdi
0x11119d56b <+34>: callq *%r13
0x11119d56e <+37>: movq %rax, %r14
0x11119d571 <+40>: movq %rbx, %rdi
0x11119d574 <+43>: callq *%r13
0x11119d577 <+46>: movq %rax, %r15
0x11119d57a <+49>: leaq 0x158700b(%rip), %r13 ; _UIApplicationLinkedOnVersion
0x11119d581 <+56>: movl (%r13), %eax
0x11119d585 <+60>: testl %eax, %eax
0x11119d587 <+62>: jne 0x11119d597 ; <+78>
0x11119d589 <+64>: cmpq $-0x1, 0x157fc7f(%rip) ; WebKitSetIsClassic + 7
0x11119d591 <+72>: jne 0x11119d60a ; <+193>
0x11119d593 <+74>: movl (%r13), %eax
0x11119d597 <+78>: cmpl $0x20100, %eax ; imm = 0x20100
0x11119d59c <+83>: jb 0x11119d5c2 ; <+121>
0x11119d59e <+85>: callq 0x11200f0a8 ; symbol stub for: objc_autoreleasePoolPush
0x11119d5a3 <+90>: movq %rax, %r13
0x11119d5a6 <+93>: movl %r12d, %edi
0x11119d5a9 <+96>: movq -0x30(%rbp), %rsi
0x11119d5ad <+100>: movq %r14, %rdx
0x11119d5b0 <+103>: movq %r15, %rcx
0x11119d5b3 <+106>: callq 0x11119d622 ; _UIApplicationMainPreparations
0x11119d5b8 <+111>: movq %r13, %rdi
0x11119d5bb <+114>: callq 0x11200f0a2 ; symbol stub for: objc_autoreleasePoolPop
0x11119d5c0 <+119>: jmp 0x11119d5d4 ; <+139>
0x11119d5c2 <+121>: movl %r12d, %edi
0x11119d5c5 <+124>: movq -0x30(%rbp), %rsi
0x11119d5c9 <+128>: movq %r14, %rdx
0x11119d5cc <+131>: movq %r15, %rcx
0x11119d5cf <+134>: callq 0x11119d622 ; _UIApplicationMainPreparations
0x11119d5d4 <+139>: movq 0x1586ef5(%rip), %rdi ; UIApp
0x11119d5db <+146>: movq 0x14d2b06(%rip), %rsi ; "_run"
0x11119d5e2 <+153>: callq *0x115d000(%rip) ; (void *)0x0000000114a20940: objc_msgSend
0x11119d5e8 <+159>: movq 0x115d001(%rip), %rbx ; (void *)0x0000000114a1dcc0: objc_release
0x11119d5ef <+166>: movq %r15, %rdi
0x11119d5f2 <+169>: callq *%rbx
0x11119d5f4 <+171>: movq %r14, %rdi
0x11119d5f7 <+174>: callq *%rbx
0x11119d5f9 <+176>: xorl %eax, %eax
0x11119d5fb <+178>: addq $0x8, %rsp
0x11119d5ff <+182>: popq %rbx
0x11119d600 <+183>: popq %r12
0x11119d602 <+185>: popq %r13
0x11119d604 <+187>: popq %r14
0x11119d606 <+189>: popq %r15
0x11119d608 <+191>: popq %rbp
0x11119d609 <+192>: retq
0x11119d60a <+193>: leaq 0x157fbff(%rip), %rdi ; _UIApplicationLinkedOnVersionOnce
0x11119d611 <+200>: leaq 0x1160910(%rip), %rsi ; __block_literal_global.1491
0x11119d618 <+207>: callq 0x11200edf6 ; symbol stub for: dispatch_once
0x11119d61d <+212>: jmp 0x11119d593 ; <+74>
First, cancel the searchController
[self searchBarCancelButtonClicked:yourSearchBar];
or
[self.searchDisplayController setActive:NO animated:YES];
and then dismiss the view controller.
[self dismissViewControllerAnimated:YES completion:nil];
This will help.