【问题标题】:EGOTableViewPullRefresh crash when over-releasing the view过度释放视图时 EGOTableViewPullRefresh 崩溃
【发布时间】:2012-04-24 16:15:38
【问题描述】:

我嵌入了我的项目 EGOTableViewPullRefresh,一切正常并且更新正常,但是当我将视图拉下太多以进行更新时,应用程序崩溃并出现错误:

2012-04-24 19:02:56.670 测试 [3927: f803] * 终止应用程序到期 未捕获的异常 'NSRangeException',原因:'* - [__NSArrayM objectAtIndex:]: 索引 2 超出空数组的范围' * 首先抛出调用栈:

一段代码

self.tabBarController = [[[UITabBarController alloc] init] autorelease];
NSMutableArray * viewControllers = [[NSMutableArray alloc] init];


//plist file full path
NSString *urlStr = [[NSString alloc] 
                    initWithFormat:@"http://www.test.com/data.xml?seedVar=%f", 
                    (float)random()/RAND_MAX];
NSURL *url = [NSURL URLWithString:urlStr];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfURL:url];

  //Get the folder array
NSArray * subscriptionFolders = [dict objectForKey:@"Folders"];

更新

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
        [cell.textLabel setNumberOfLines:2];
        [cell.detailTextLabel setNumberOfLines:3];
        [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
    }

    RSSItem * rssItem = (RSSItem *)[_rssParser.rssItems objectAtIndex:indexPath.row];
    [cell.textLabel setText:rssItem.title];
    [cell.detailTextLabel setText:rssItem.summary];

    return cell;
}

你能帮我解决这个问题吗?

【问题讨论】:

  • 我在这里看不到任何数组。因此,您在其他地方崩溃了...查看您在代码中访问数组的位置。既然你提到了 EGOTableVIew,我猜你在 tableview 数据源 cellForRowAtIndexPath 函数中崩溃了
  • 你是这个意思吗?查看更新的代码

标签: iphone ios xcode pull-to-refresh


【解决方案1】:

我找到了解决方案。当我在 reloadTableViewDataSource 中调用 rssParser 时,它崩溃了。当我尝试在 dataSourceDidFinishLoadingNewData 中调用 rssParser 时,一切正常,没有崩溃。

- (void)reloadTableViewDataSource{
[super performSelector:@selector(dataSourceDidFinishLoadingNewData) withObject:nil afterDelay:2.0];
}

- (void)dataSourceDidFinishLoadingNewData{
    [_rssParser start];
    [refreshHeaderView setCurrentDate]; 
    [super dataSourceDidFinishLoadingNewData];   
}

【讨论】:

    猜你喜欢
    • 2011-07-19
    • 1970-01-01
    • 2011-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-22
    • 1970-01-01
    相关资源
    最近更新 更多