简体   繁体   English

单击详细信息页面上的自定义后退按钮可崩溃的应用程序(仅在iOS8中)

[英]Click on custom back button from detail page to previous tableview is crashing app (in only iOS8)

I have a app with following structure 我有一个具有以下结构的应用程序

first i have a button in my home page when i click that it will open a new UITableView and display list of "Main Programs" When a user click on any of those will open another view controller and display all "Sub Programs" in that user can select each sub programs to see the details. 首先,当我单击它时,我在主页上有一个按钮,它将打开一个新的UITableView并显示“主程序”列表。当用户单击其中任何一个时,将打开另一个视图控制器并显示该用户中的所有“子程序”可以选择每个子程序以查看详细信息。

All these are working fine till iOS 7 versions. 所有这些在iOS 7版本之前都可以正常工作。 Recently i upgraded device to iOS 8 (iPad and iPhone) then i run the same code and when we return from "Sub Program Detail " page to "Sub Program" Page App is crashing. 最近,我将设备升级到iOS 8(iPad和iPhone),然后运行相同的代码,当我们从“子程序详细信息”页面返回到“子程序”页面时,应用程序崩溃。 There is no log message .Only am getting this one Please help ,The back button is working fine but something in that previous tableview controller not working . 没有日志消息。仅收到此消息,请帮助,“后退”按钮工作正常,但先前的tableview控制器中的某项不起作用。

在此处输入图片说明

i tried to do instrumentation then i got following message http://postimg.org/image/ytezux0m9/ 我尝试进行检测,然后收到以下消息http://postimg.org/image/ytezux0m9/

Then i tried to debug it but i couldnt find anything wrong there (every value was correct) and then i tried to add "tableview relaod data" to ViewWillAppear () .And then i got a crash log like this 然后我尝试调试它,但是我在那里找不到任何错误(每个值都是正确的),然后尝试向ViewWillAppear()添加“ tableview relaod数据”。然后我得到了这样的崩溃日志

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UISearchDisplayController numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x124e6e7a0'
*** First throw call stack:
(0x1872ee084 0x1978d40e4 0x1872f5094 0x1872f1e48 0x1871f708c 0x18be51d38 0x18bb49480 0x18bb491f4 0x18bb4fe74 0x18ba6d140 0x18ba8e4c8 0x18ba6ce58 0x18ba6ce58 0x18ba8e4c8 0x18ba6ce58 0x18ba6ce58 0x18ba6ce58 0x18ba6c528 0x18ba6c408 0x18ba77ea4 0x18bc5ab18 0x18ba7e77c 0x18bc5a3a4 0x18bc14278 0x18bb24f40 0x18bb24d0c 0x18bb24c8c 0x18ba6d874 0x18b3c5d58 0x18b3c0944 0x18b3c07e8 0x18b3bffe8 0x18b3bfd6c 0x18ba6f790 0x1872a6324 0x1872a55c8 0x1872a3678 0x1871d1664 0x1903135a4 0x18bad64f8 0x1000a4c80 0x197f42a08)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

Just now i run then i got this in my log 刚才我跑了,那我就记在日志里了

-[UITextFieldLabel numberOfSectionsInTableView:]: unrecognized selector sent to instance 0x12fe79f70

UPDATES : 更新 :

one more thing like when i going forward my if condition is true and when i click back button its geting false and execute else part for - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section method code is here http://postimg.org/image/kikrbltj1/ 还有另外一件事,例如当我继续执行if条件为true时,以及当我单击后退按钮时,它会为false并执行-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)部分的其他方法代码,位于此处http: //postimg.org/image/kikrbltj1/

I think the reason for the crash is that when you click on the back button from detail, popViewController is called twice. 我认为发生崩溃的原因是,当您从详细信息单击后退按钮时,popViewController被调用了两次。 The navigation controller firstly pops the "Sub Program Detail" page, and then immediately pops the "Sub Program" Page. 导航控制器首先弹出“子程序详细信息”页面,然后立即弹出“子程序”页面。 In the "Sub Program" viewWillAppear method, a setupContainer method is executed and loading some FKRSearchBarTableViewController which has table to be filled. 在“子程序” viewWillAppear方法中,将执行setupContainer方法并加载一些FKRSearchBarTableViewController,该表具有要填充的内容。

So when the navigation controller firstly pop the "Sub Program Detail" Page, app goes to the "Sub Program" page's viewWillAppear method, where setupContainer is executed and tables are loading data, at the same time, "Sub Program" page is poped out."Sub Program" is dealloc'ed, So are the FKRSearchBarTableViewControllers, which are busy loading their tableViews. 因此,当导航控制器首先弹出“子程序详细信息”页面时,应用程序转到“子程序”页面的viewWillAppear方法,在其中执行setupContainer并且表正在加载数据,同时弹出“子程序”页面。“子程序”已取消分配,正在忙于加载其tableViews的FKRSearchBarTableViewControllers也已取消分配。 That's why message sent to dealloc'ed object. 这就是为什么消息发送到取消分配的对象。

You can move the line [self setupContainer] in DAViewController from viewWillAppear to the end of viewDidLoad , and remove the lines 您可以将DAViewController [self setupContainer] DAViewControllerviewWillAppear移到viewDidLoad的末尾,然后删除这些行

if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
    // Navigation button was pressed. Do some stuff
    [self.navigationController popViewControllerAnimated:YES];
}

from viewWillDisappear in THProgramDetailsViewController.m . viewWillDisappearTHProgramDetailsViewController.m

Since in backBtnClick method, pop action has already been executed. 由于在backBtnClick方法中,弹出操作已经执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM