刷新Tableview控制器时UIRefreshControl崩溃

时间:2013-02-25 22:23:32

标签: iphone ios asynchronous uirefreshcontrol

我无法刷新我的 TVC。当我向下拖动以刷新时崩溃。图标在那里,但随后退出。我确信这很简单。有类似的问题没有被考虑过。

取自我的viewDidLoad方法体:

refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self
                   action:@selector(refreshInvoked:forState:)
         forControlEvents:UIControlEventValueChanged];
[self.tableView addSubview:refreshControl];

refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:title
                                                            attributes:@{NSFontAttributeName:[UIFont fontWithName:@"Helvetica" size:13.0]}];
[self refreshFeed];

指的是:

-(void)refreshFeed 
{
   RSSLoader* rss = [[RSSLoader alloc] init];    
   [rss fetchRssWithURL:feedURL
            complete:^(NSString *title, NSArray *results) {
                dispatch_queue_t downloadQueue = dispatch_queue_create("downloader",NULL);
                dispatch_async(downloadQueue, ^{
                _objects = results;
                    [self.tableView reloadData];
                //completed fetching the RSS
                dispatch_async(dispatch_get_main_queue(), ^{
     //               [(HeaderView*)self.tableView.tableHeaderView setText:title];
                    // [(ArticleItem*)self.tableView.]
                });
                });
    }];
}

2 个答案:

答案 0 :(得分:4)

UIRefreshControl并不打算作为子视图添加 ...这样做会给你带来一些麻烦,你需要在VC dealloc上取消注册它的目标......否则你可能会遇到一些问题,当时UIRefreshControl调用你死的VC(因为它没有对你的VC保持弱或强引用)

答案 1 :(得分:3)

将您的操作方法更改为:

[refreshControl addTarget:self
                   action:@selector(refreshFeed)
         forControlEvents:UIControlEventValueChanged];

看起来你指的是自我中没有的refreshInvoked:forState:

相关问题