我有VC1标签(显示任务数量)。 在VC2中我有我的所有任务在tableView中,我可以删除它们(保存在COREDATA中的任务)如何刷新数据和查看?
问题是如果我有5个任务标签显示我“05”但是当我去VC2并删除一个任务,回到VC1,它会在相同的标签和相同的位置显示我“05”和“04”,就像VC1做'屏幕截图'一样。当我转到其他VC或重新加载APP时,这将是正常的。
为什么发生这种情况?我该如何解决它?
tnx,并对我的英语感到抱歉。
在viewDidAppear:
// fetchData FROM CORE DATA Tasks //
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entityTasks = [NSEntityDescription entityForName:@"Device" inManagedObjectContext:[self managedObjectContext]];
[fetchRequest setEntity:entityTasks];
NSError *errorTasks = nil;
fetchedObjectsTasks = [[self managedObjectContext] executeFetchRequest:fetchRequest error:&errorTasks];
if (fetchedObjectsTasks == nil) {
NSLog(@"Problem with fetch! %@",errorTasks);
}
numberOfIssues = [NSMutableArray arrayWithObjects:[NSString stringWithFormat:@"%lu",(unsigned long)fetchedObjectsTasks.count],nil];
在TableCell的:
numberOfIssueLabelView.frame = CGRectMake(224, 11, 20, 21);
numberOfIssueLabelView = [[UILabel alloc] initWithFrame:numberOfIssueLabelView.frame];
numberOfIssueLabelView.text = [numberOfIssues objectAtIndex:(indexPath.row)];
numberOfIssueLabelView.font = [UIFont systemFontOfSize:15.0f];
numberOfIssueLabelView.textColor = [UIColor whiteColor];
[cell addSubview:self.numberOfIssueLabelView];
return cell;
当你不能添加或删除任务的工作很好,我觉得需要VC1得到一些刷新。
与我们分享您的代码,特别是您在VC1中为标签设置文本的位置 –