iOS过滤tableview导航推送UIView,然后UIView返回导致crash
Posted
技术标签:
【中文标题】iOS过滤tableview导航推送UIView,然后UIView返回导致crash【英文标题】:iOS filtered tableview navigation push UIView, then UIView back causing crash 【发布时间】:2015-05-04 12:53:35 【问题描述】:有人遇到过同样令人烦恼的问题吗?我不知道 UIView 会将发布消息发送给谁。
非常感谢您的建议。
我的测试代码严格遵循 Apple tableView/Search 示例代码指南。初始 TableView 完美运行。并触发过滤后的tableView显示在UISearchController -> searchResultsController,代码如下。
func updateSearchResultsForSearchController(searchController: UISearchController)
...
let tableController = self.searchController!.searchResultsController as! FilteredTableViewController
tableController.datasource = self.tableData?.tableFilteredCellRecords
tableController.navController = self.navigationController
tableController.tableView.reloadData()
...
在过滤后的tableView中,单元格行显示OK,然后点击任意单元格触发详细UIView显示,代码如下:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
let record = self.tableData!.getFilteredTableRecord(indexPath.row)
if(record != nil)
let detailViewController = DetailViewController()
detailViewController.titleText = record?.title
detailViewController.descText = record?.desc
detailViewController.imgExist = record!.imgview
self.navigationController?.pushViewController(detailViewController, animated: false)
然后详细的UIView显示很好,但是当点击'Back'按钮返回TableView时,App崩溃了。
启用僵尸后,调试报告:
(lldb)
Optional("A server with the specified hostname could not be found.")
2015-05-04 22:45:31.687 Swift_UI_programmatically[2057:419330] *** -[UIViewControllerWrapperView release]: message sent to deallocated instance 0x7fdefe0d8250
(lldb)
0x102db5f49 <+489>: callq *0x3062a1(%rip) ; (void *)0x0000000102b08000: objc_msgSend
0x102db5f4f <+495>: jmp 0x102db5f72 ; <+530>
0x102db5f51 <+497>: movq %r14, %rdi
0x102db5f54 <+500>: callq 0x102eaff58 ; symbol stub for: object_getClassName
0x102db5f59 <+505>: movq %rax, %rcx
0x102db5f5c <+508>: leaq 0x32cabd(%rip), %rsi ; @"*** NSForwarding: warning: object %p of class '%s' does not implement forwardInvocation: -- dropping message"
0x102db5f63 <+515>: movl $0x4, %edi
0x102db5f68 <+520>: xorl %eax, %eax
0x102db5f6a <+522>: movq %r14, %rdx
0x102db5f6d <+525>: callq 0x102dfd000 ; CFLog
0x102db5f72 <+530>: movq 0x34b0a7(%rip), %rax ; NSInvocation._retainedArgs
0x102db5f79 <+537>: cmpb $0x0, (%rbx,%rax)
0x102db5f7d <+541>: je 0x102db5fb1 ; <+593>
0x102db5f7f <+543>: movq (%r13), %rax
0x102db5f83 <+547>: testb $-0x80, 0x22(%rax)
0x102db5f87 <+551>: je 0x102db5fb1 ; <+593>
0x102db5f89 <+553>: movq 0x34b080(%rip), %rcx ; NSInvocation._frame
0x102db5f90 <+560>: movq (%rbx,%rcx), %rcx
0x102db5f94 <+564>: movl 0x1c(%rax), %edx
0x102db5f97 <+567>: movzbl 0x20(%rax), %esi
0x102db5f9b <+571>: addq %rdx, %rsi
0x102db5f9e <+574>: movq (%r15,%rsi), %rdi
0x102db5fa2 <+578>: movq (%rcx,%rsi), %rsi
0x102db5fa6 <+582>: movq (%rax), %rax
0x102db5fa9 <+585>: movl 0x10(%rax), %edx
0x102db5fac <+588>: callq 0x102eb04b0 ; symbol stub for: memmove
0x102db5fb1 <+593>: movq 0x34b050(%rip), %rax ; NSInvocation._retdata
0x102db5fb8 <+600>: movq (%rbx,%rax), %r15
0x102db5fbc <+604>: movq 0x34a02d(%rip), %rsi ; "methodReturnType"
0x102db5fc3 <+611>: movq %r12, %rdi
0x102db5fc6 <+614>: callq *0x306224(%rip) ; (void *)0x0000000102b08000: objc_msgSend
0x102db5fcc <+620>: movzbl (%rax), %eax
0x102db5fcf <+623>: cmpl $0x44, %eax
0x102db5fd2 <+626>: jne 0x102db6009 ; <+681>
0x102db5fd4 <+628>: fldt (%r15)
0x102db5fd7 <+631>: jmp 0x102db6009 ; <+681>
0x102db5fd9 <+633>: movq %rax, %rbx
0x102db5fdc <+636>: movq %rbx, %rdi
0x102db5fdf <+639>: callq 0x102e60560 ; getAtomTarget
0x102db5fe4 <+644>: movq %rax, %r12
0x102db5fe7 <+647>: movq %r12, (%r15,%r14)
0x102db5feb <+651>: movl $0x400, %ecx
0x102db5ff0 <+656>: xorl %r8d, %r8d
0x102db5ff3 <+659>: movq %r13, %rdi
0x102db5ff6 <+662>: movq %r15, %rsi
0x102db5ff9 <+665>: movq %r15, %rdx
0x102db5ffc <+668>: callq 0x102d4ed60 ; __invoking___
0x102db6001 <+673>: cmpq %r12, (%r15)
0x102db6004 <+676>: jne 0x102db6009 ; <+681>
0x102db6006 <+678>: movq %rbx, (%r15)
0x102db6009 <+681>: movq %r15, %rax
0x102db600c <+684>: addq $0x18, %rsp
0x102db6010 <+688>: popq %rbx
0x102db6011 <+689>: popq %r12
0x102db6013 <+691>: popq %r13
0x102db6015 <+693>: popq %r14
0x102db6017 <+695>: popq %r15
0x102db6019 <+697>: popq %rbp
0x102db601a <+698>: retq
0x102db601b <+699>: leaq 0x35638e(%rip), %rax ; __CFOASafe
0x102db6022 <+706>: cmpb $0x0, (%rax)
0x102db6025 <+709>: je 0x102db603b ; <+731>
0x102db6027 <+711>: movl $0x15, %edi
0x102db602c <+716>: xorl %edx, %edx
0x102db602e <+718>: xorl %ecx, %ecx
0x102db6030 <+720>: xorl %r8d, %r8d
0x102db6033 <+723>: movq %r13, %rsi
0x102db6036 <+726>: callq 0x102e30880 ; __CFRecordAllocationEvent
0x102db603b <+731>: addq $0xa, %rbx
0x102db603f <+735>: movq -0x30(%rbp), %rdi
0x102db6043 <+739>: callq 0x102eaff76 ; symbol stub for: sel_getName
0x102db6048 <+744>: movq %rax, %rcx
0x102db604b <+747>: leaq 0x32c90e(%rip), %rdx ; @"*** -[%s %s]: message sent to deallocated instance %p"
0x102db6052 <+754>: movl $0x3, %edi
0x102db6057 <+759>: xorl %eax, %eax
0x102db6059 <+761>: movq %rdx, %rsi
0x102db605c <+764>: movq %rbx, %rdx
0x102db605f <+767>: movq %r13, %r8
0x102db6062 <+770>: callq 0x102dfd000 ; CFLog
0x102db6067 <+775>: int3
-> 0x102db6068 <+776>: jmp 0x102db6167 ; <+1031>
0x102db606d <+781>: movq %r12, %rdi
【问题讨论】:
【参考方案1】:试试这个
self.view = [[UIView alloc]initWithFrame:self.view.frame];
当改变 viewController..
【讨论】:
【参考方案2】:在阅读了 *** 中的许多讨论后,终于得到了一个有用的建议,并且确实有效。 '不要同时推送两个动画视图控制器。推第一个不带动画,推第二个带动画。 UINavigationController 不能同时处理两个动画'
UINavigationController crash because of pushing and poping UIViewControllers
最后只改一行代码:self.navigationController?.pushViewController(),设置动画为真。这个错误是固定的。我不敢相信这是 ios 错误,或者一些未知的知识。
【讨论】:
以上是关于iOS过滤tableview导航推送UIView,然后UIView返回导致crash的主要内容,如果未能解决你的问题,请参考以下文章
iOS11 中奇怪的 uitableview 行为。单元格通过导航推送动画向上滚动