我第一次使用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/