ios - 由于UIRefreshControl而导致异常

标签 ios ios6 uirefreshcontrol

我第一次使用UIRefreshControl,并且在刷新控件加载期间出现异常。

这里是我的报关表 :

self.refreshControl = [[UIRefreshControl alloc] init];
self.refreshControl.tintColor = [UIColor grayColor];
[self.refreshControl addTarget:self action:@selector(refreshView:) forControlEvents:UIControlEventValueChanged];
[self.actualitesTableView addSubview:self.refreshControl];

这是我的功能:
- (void)refreshView:(UIRefreshControl *)sender {
    [self performSelectorInBackground:@selector(threadAction) withObject:nil];
}

- (void)threadAction {
    [self choixMAJ];
    NSLog(@"OK1");
    [self.refreshControl endRefreshing];
    NSLog(@"OK2");
}

当我使用choixMAJ()方法时,它可以完美地工作。

一切正常,并记录了OK2,但是在此之后,当刷新控件消失时,应用程序因以下错误而崩溃:
*** -[__NSArrayM removeObject:]: message sent to deallocated instance 0x655a1a0

我不明白为什么。有什么想法吗?

最佳答案

好吧,对于初学者,您不应该在后台线程上调用-endRefreshing。 UIKit方法(包括该方法)应在主线程上执行。不过,我不确定这实际上是造成您的问题的原因。

谢谢shusta,它对我有很大帮助!

关于ios - 由于UIRefreshControl而导致异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13199344/

相关文章:

ios - 以编程方式更改 Xib 方向的最佳方法

objective-c - 检测 UITextfield 中文本的更改

ios - UITableViewCell 框架高度始终为 44px

ios - UIRefreshControl 卡在最后一个拖动步骤

ios - 应用程序在重新加载和向一个方向滚动 tableview 时崩溃

ios - 如何使用 facebook SDK 检查 iOS 中是否安装了 fbmessanger

iphone - UIViewController childViewControllers 数组上的 KVO

ios - 如何从单一 View 转到 spritekit

objective-c - 使用 cocos2d 的 onEnter 方法

ios - UIRefreshControl 在 UITableViewController 中的位置错误