Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Uitableview 当我向上滚动到顶部并按住时,Tableview崩溃_Uitableview_Xcode5 - Fatal编程技术网

Uitableview 当我向上滚动到顶部并按住时,Tableview崩溃

Uitableview 当我向上滚动到顶部并按住时,Tableview崩溃,uitableview,xcode5,Uitableview,Xcode5,我有一个由核心数据提供的表视图。它工作正常,除非我滚动回到顶部并保持在那里。然后应用程序崩溃。 有什么建议吗? 谢谢 //这个类的模型。 // //当它被设置时,我们创建一个NSFetchRequest来获取数据库中与它相关联的所有摄影师。 //然后,我们使用NSFetchedResultsController将NSFetchRequest挂接到表视图 - (void)setManagedObjectContext:(NSManagedObjectContext *)managedObjectC

我有一个由核心数据提供的表视图。它工作正常,除非我滚动回到顶部并保持在那里。然后应用程序崩溃。 有什么建议吗? 谢谢

//这个类的模型。 // //当它被设置时,我们创建一个NSFetchRequest来获取数据库中与它相关联的所有摄影师。 //然后,我们使用NSFetchedResultsController将NSFetchRequest挂接到表视图

- (void)setManagedObjectContext:(NSManagedObjectContext *)managedObjectContext
{
    _managedObjectContext = managedObjectContext;
    if (managedObjectContext) {
        NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"TestResults"];
        request.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"date" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)]];
        request.predicate = nil; // all records

        self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:managedObjectContext sectionNameKeyPath:nil cacheName:nil];
    } else {
        self.fetchedResultsController = nil;
    }
}

#pragma mark - UITableViewDataSource

// Uses NSFetchedResultsController's objectAtIndexPath: to find the Photographer for this row in the table.
// Then uses that Photographer to set the cell up.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TestResults"];

    TestResults *testResult = [self.fetchedResultsController objectAtIndexPath:indexPath];

    [self showTestResult:testResult];


    // show traffic light color


    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"MM-dd-yy hh:mm a"];
    NSString *theDate = [dateFormatter stringFromDate:testResult.date];

    cell.textLabel.text = theDate;
    cell.detailTextLabel.text = testResult.overallPassOrFail;

    NSLog(@"overall: %@", testResult.overallPassOrFail);
    NSLog(@"light color: %@", testResult.trafficLightColor);

    // retrieve an image
    if ([testResult.trafficLightColor isEqualToString:@"Red"]) {
        self.lightImage = @"Red_Light";
    } else if ([testResult.trafficLightColor isEqualToString:@"Yellow"]) {
        self.lightImage = @"Yellow_Light";
    } else {
        self.lightImage = @"Green_Light";
    }
    NSString *imagefile = [[NSBundle mainBundle] pathForResource:self.lightImage ofType:@"png"];
    self.imageOne = [[UIImage alloc] initWithContentsOfFile:imagefile];
    cell.imageView.image = self.imageOne;
    //

    return cell;
}

您正在调用未实现的方法,请检查代码;)

我想看看您的代码或发送的日志消息是什么??这里是错误;2014-02-07 11:38:32.193 Me本人[1057:70b]-[HistoryViewController刷新]:未识别的选择器发送到实例0xb6b16a0 2014-02-07 11:38:32.202 Me本人[1057:70b]***由于未捕获的异常“NSInvalidArgumentException”终止应用程序,原因:'-[HistoryViewController刷新]:未识别的选择器发送到实例0xb6b16a0'确定,现在我想看看你的代码。。。这似乎是一个代码错误…这是代码。我从斯坦福ios班上借的。只有当我向下滑动手指滚动桌子时,它才会崩溃,而风车在顶部旋转,然后它就会崩溃。谢谢你的帮助。我需要看看你调用刷新方法的代码