简体   繁体   English

解雇UIActionSheet会产生EXC_BAD_ACCESS

[英]Dismissing UIActionSheet gives EXC_BAD_ACCESS

I've got an application with UITableView nested in a UITabBarController, and I have a method that's giving me an EXC_BAD_ACCESS when it's called from UIActionSheetDelegate method clickedButtonAtIndex: 我有一个UITableView嵌套在UITabBarController中的应用程序,我有一个方法,当它从UIActionSheetDelegate方法调用clickedButtonAtIndex时给我一个EXC_BAD_ACCESS:

The method that (sometimes) gives a problem is called updateTaskArray. (有时)提出问题的方法称为updateTaskArray。 Basically, it does a Core Data fetch that configures an NSMutableArray "taskArray" that's a property of the viewController (which the tableView delegate uses to configure its cells) then its last line is 基本上,它执行一个Core Data fetch来配置一个NSMutableArray“taskArray”,它是viewController的一个属性(tableView委托用来配置它的单元格)然后它的最后一行是

[self.tableView reloadData];

The thing is, it works fine most of the time, but it only gives an error when it's called from the UIActionSheetDelegate. 问题是,它在大多数情况下都能正常工作,但只有在从UIActionSheetDelegate调用它时才会出错。 When I run it with NSZombieEnabled, it tells me 当我用NSZombieEnabled运行它时,它告诉我

*** -[UITabBarButton setAlpha:]: message sent to deallocated instance 0x5c2e760

And with breakpoints, it doesn't give EXC_BAD_ACCESS until after the UIActionView delegate method (and updateTaskArray within it) complete. 并且使用断点,在UIActionView委托方法(以及其中的updateTaskArray)完成之后,它不会提供EXC_BAD_ACCESS。 The UIActionSheet is presented with: UIActionSheet提供:

[actionSheet showFromTabBar:self.tabBarController.tabBar];

so I'm wondering if this means that it's dismissing the actionSheet that is causing the problem... but it doesn't give any error if I don't call updateTaskArray from the delegate... 所以我想知道这是否意味着它正在解决导致问题的actionSheet ...但如果我不从委托调用updateTaskArray它也不会给出任何错误...

I'm not really sure what would be a good next step as [UITabBarButton setAlpha:] isn't a method I'm calling "myself" and the error seems to occur after the code I've actually "written" has already run- any suggestions on where to start approaching this one? 我不确定下一步会是什么好事,因为[UITabBarButton setAlpha:]不是我称之为“我自己”的方法,并且在我实际“编写”的代码已经运行之后似乎发生了错误 - 关于从哪里开始接近这个的任何建议?

I changed 我变了

[actionSheet showFromTabBar:self.tabBarController.tabBar];

to

[actionSheet showFromToolbar:self.navigationController.toolbar];

And it now works fine. 它现在工作正常。 The tabBarController is the parent of the navigation controller, I reckon it didn't like me going one level above. tabBarController是导航控制器的父级,我估计它不喜欢我走上一级。

Look at your release statements. 查看您的发布声明。 You are releasing a UITabBarButton, or possibly the entire tab bar, when you shouldn't. 你不应该发布UITabBarButton,或者可能是整个标签栏。 Review principles of memory management for iOS. 回顾iOS的内存管理原则。

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

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