IOS 7桌面视图循环
我正在iPhone 4设备的iOS7上努力解决这个奇怪的问题,不确定这是否发生在新版本或设备上。我没有设法在我的iPhone6上复制这个问题,目前我使用的是iOS11测试版IOS 7桌面视图循环,ios,objective-c,iphone,uitableview,ios7,Ios,Objective C,Iphone,Uitableview,Ios7,我正在iPhone 4设备的iOS7上努力解决这个奇怪的问题,不确定这是否发生在新版本或设备上。我没有设法在我的iPhone6上复制这个问题,目前我使用的是iOS11测试版 I have a Tableview with a NSFetchecResult as the table datasource. The problem appears when I scroll the table this loop randomly happens. this is the log: 这是我在
I have a Tableview with a NSFetchecResult as the table datasource.
The problem appears when I scroll the table this loop randomly happens.
this is the log:
这是我在coredata更改时管理的
#pragma标记-NSFetchResultsControllerDelegate
-(void)controllerWillChangeContent:(NSFetchedResultsController*)控制器
{
如果(!\u是crowling)
{
NSLog(@“TableView开始更新”);
[self.tableView开始更新];
}
其他的
_tableViewNeedsToUpdate=是;
}
-(void)控制器:(NSFetchedResultsController*)控制器didChangeObject:(id)索引路径中的一个对象:(NSIndexPath*)变更类型的indexPath:(NSFetchedResultsChangeType)类型newIndexPath:(NSIndexPath*)newIndexPath
{
如果(!\u是crowling)
{
开关(类型){
案例NSFetchedResultsChangesInsert:
NSLog(@“didChangeObject->NSFetchedResultsChangeInsert”);
[self.tableView insertRowsAtIndexPaths:@[indexath]带行动画:uitableview行动画自动];
打破
案例NSFetchedResultsChangeDelete:
NSLog(@“didChangeObject->NSFetchedResultsChangeDelete”);
[self.tableView deleteRowsAtIndexPaths:@[indexPath]with RowAnimation:UITableViewRowAnimationAutomatic];
打破
案例NSFetchedResultsChangeUpdate:
NSLog(@“didChangeObject->NSFetchedResultsChangeUpdate”);
[self-configureCell:[self.tableView CellForRowatineXpath:indexPath]AtiXpath:indexPath];
打破
案例NSFetchedResultsChangeMove:
NSLog(@“didChangeObject->NSFetchedResultsChangeMove”);
[self.tableView deleteRowsatindExpath:[NSArray arrayWithObject:indexPath]带RowAnimation:UITableViewRowAnimationFade];
[self.tableView insertRowsAtIndexPaths:[NSArray arraywhithobject:newindexath]with rownanimation:uitableviewrownanimationfade];
打破
}
}
}
-(void)控制器:(NSFetchedResultsController*)控制器didChangeSection:(id)sectionInfo atIndex:(nsInteger)ChangeType的sectionIndex:(NSFetchedResultsChangeType)类型
{
如果(!\u是crowling)
{
开关(类型){
案例NSFetchedResultsChangesInsert:
NSLog(@“didChangeSection->NSFetchedResultsChangeInsert”);
[self.tableView insertSections:[NSIndexSet IndexSetWithiIndex:sectionIndex]带RowAnimation:UITableViewRowAnimationFade];
打破
案例NSFetchedResultsChangeDelete:
NSLog(@“didChangeSection->NSFetchedResultsChangeDelete”);
[self.tableView deleteSections:[NSIndexSet IndexSetWithiIndex:sectionIndex]带RowAnimation:UITableViewRowAnimationFade];
打破
违约:
打破
}
}
}
-(void)controllerDidChangeContent:(NSFetchedResultsController*)控制器
{
如果(!\u是crowling)
{
[self.tableView endUpdates];
NSLog(@“TableView结束更新”);
}
}
这是我在做桌面视图的事情
#pragma标记-UITableView数据源和委托
-(NSInteger)表格视图中的节数:(UITableView*)表格视图
{
NSLog(@“numberOfSectionsInTableView”);
NSInteger nSections=0;
id sectionInfo=[self.fechredResultController sections];
nSections=[sectionInfo计数];
NSLog(@“numberOfSectionsInTableView->%li”,(长)个分区);
返回不连续项;
}
-(UIView*)表格视图:(UITableView*)表格视图用于标题部分:(NSInteger)部分
{
NSLog(@“viewForHeaderSection:%li”,(长)节);
id sectionInfo=[[self.fechedResultController sections]objectAtIndex:section];
如果(节信息)
{
NSString*sectionName=[[[sectionInfo对象]第一对象]组]名称];
UIView*标题=[[UIView alloc]initWithFrame:CGRectMake(0,0,tableView.frame.size.width,28)];
[header setBackgroundColor:[UIColor lightGrayColor]];
UILabel*headerText=[[UILabel alloc]initWithFrame:CGRectMake(18,4,tableView.frame.size.width-(18*2,20)];
[headerText setTextColor:[UIColor blackColor]];
[headerText setFont:[UIFont fontWithName:@“Arial BoldMT”大小:20];
[headerText-setText:sectionName];
[标题添加子视图:标题文本];
返回头;
}
其他的
返回零;
}
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节
{
//NSLog(@“numberOfRowsInSection:%i”,section);
NSInteger nRows=0;
id sectionInfo=self.fechredResultController.sections[section];
nRows=sectionInfo.numberOfObjects;
NSLog(@“numberOfRowsInSection:%li->%li”,(长)section,(长)nRows);
返回nRows;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
NSLog(@“cellforrowatinexpath:%@,[indexath描述]);
//NSInteger section=indexPath.section;
//NSInteger行=indexPath.row;
FilterListTableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:@“cell]”;
如果(单元格==nil)
单元格=[[FilterListTableViewCell alloc]init];
[单元格设置MyDelegate:self];
id dataObject=[self.fechedResultController objectAtIndexPath:indexPath];
[cell setCellForObject:dataObject];
返回单元;
}
-(void)configureCell:(FilterListTableViewCell*)单元格atIndexPath:(NSIndexPath*)indexPath
{
2017-07-14 10:13:21.158 APP[28317:60b] cellForRowAtIndexPath <NSIndexPath: 0x18a58970> {length = 2, path = 3 - 0}
2017-07-14 10:13:21.223 APP[28317:60b] viewForHeaderInSection:4
2017-07-14 10:13:21.241 APP[28317:60b] cellForRowAtIndexPath:<NSIndexPath: 0x18f35450> {length = 2, path = 4 - 0}
2017-07-14 10:13:21.293 APP[28317:60b] scrollViewDidEndDragging -> notScrolling
2017-07-14 10:13:21.318 APP[28317:60b] scrollViewDidScroll -> isScrolling
2017-07-14 10:13:21.335 APP[28317:60b] viewForHeaderInSection:5
2017-07-14 10:13:21.354 APP[28317:60b] cellForRowAtIndexPath:
<NSIndexPath: 0x18f34910> {length = 2, path = 5 - 0}
2017-07-14 10:13:21.404 APP[28317:60b] viewForHeaderInSection:6
2017-07-14 10:13:21.420 APP[28317:60b] cellForRowAtIndexPath:<NSIndexPath: 0x18f50cf0> {length = 2, path = 6 - 0}
2017-07-14 10:13:21.825 APP[28317:60b] scrollViewDidEndDecelerating -> >notScrolling
2017-07-14 10:13:21.855 APP[28317:60b] scrollViewWillBeginDragging -> isScrolling
2017-07-14 10:13:21.887 APP[28317:60b] cellForRowAtIndexPath:<NSIndexPath: 0x1763b350> {length = 2, path = 2 - 0}
2017-07-14 10:13:21.920 APP[28317:60b] viewForHeaderInSection:2
2017-07-14 10:13:21.958 APP[28317:60b] cellForRowAtIndexPath:<NSIndexPath: 0x18acb2b0> {length = 2, path = 1 - 0}
2017-07-14 10:13:21.992 APP[28317:60b] cellForRowAtIndexPath:<NSIndexPath: 0x18a2e640> {length = 2, path = 0 - 0}
2017-07-14 10:13:22.054 APP[28317:60b] viewForHeaderInSection:0
2017-07-14 10:13:22.070 APP[28317:60b] viewForHeaderInSection:1
2017-07-14 10:13:22.092 APP[28317:60b] numberOfSectionsInTableView
2017-07-14 10:13:22.100 APP[28317:60b] numberOfSectionsInTableView -> 7
2017-07-14 10:13:22.105 APP[28317:60b] numberOfRowsInSection:6 -> 1
2017-07-14 10:13:22.108 APP[28317:60b] numberOfRowsInSection:0 -> 1
2017-07-14 10:13:22.117 APP[28317:60b] numberOfRowsInSection:1 -> 1
2017-07-14 10:13:22.136 APP[28317:60b] numberOfRowsInSection:2 -> 1
2017-07-14 10:13:22.140 APP[28317:60b] numberOfRowsInSection:3 -> 1
2017-07-14 10:13:22.144 APP[28317:60b] numberOfRowsInSection:4 -> 1
2017-07-14 10:13:22.154 APP[28317:60b] numberOfRowsInSection:5 -> 1
2017-07-14 10:13:22.275 APP[28317:60b] numberOfSectionsInTableView
2017-07-14 10:13:22.284 APP[28317:60b] numberOfSectionsInTableView -> 7
2017-07-14 10:13:22.288 APP[28317:60b] numberOfRowsInSection:6 -> 1
2017-07-14 10:13:22.291 APP[28317:60b] numberOfRowsInSection:0 -> 1
2017-07-14 10:13:22.298 APP[28317:60b] numberOfRowsInSection:1 -> 1
2017-07-14 10:13:22.303 APP[28317:60b] numberOfRowsInSection:2 -> 1
2017-07-14 10:13:22.306 APP[28317:60b] numberOfRowsInSection:3 -> 1
2017-07-14 10:13:22.309 APP[28317:60b] numberOfRowsInSection:4 -> 1
2017-07-14 10:13:22.317 APP[28317:60b] numberOfRowsInSection:5 -> 1
2017-07-14 10:13:22.536 APP[28317:60b] numberOfSectionsInTableView
2017-07-14 10:13:22.540 APP[28317:60b] numberOfSectionsInTableView -> 7
2017-07-14 10:13:22.543 APP[28317:60b] numberOfRowsInSection:6 -> 1
2017-07-14 10:13:22.565 APP[28317:60b] numberOfRowsInSection:0 -> 1
2017-07-14 10:13:22.569 APP[28317:60b] numberOfRowsInSection:1 -> 1
2017-07-14 10:13:22.572 APP[28317:60b] numberOfRowsInSection:2 -> 1
2017-07-14 10:13:22.576 APP[28317:60b] numberOfRowsInSection:3 -> 1
2017-07-14 10:13:22.585 APP[28317:60b] numberOfRowsInSection:4 -> 1
2017-07-14 10:13:22.589 APP[28317:60b] numberOfRowsInSection:5 -> 1
2017-07-14 10:13:22.737 APP[28317:60b] numberOfSectionsInTableView
2017-07-14 10:13:22.741 APP[28317:60b] numberOfSectionsInTableView -> 7
2017-07-14 10:13:22.748 APP[28317:60b] numberOfRowsInSection:6 -> 1
2017-07-14 10:13:22.752 APP[28317:60b] numberOfRowsInSection:0 -> 1
2017-07-14 10:13:22.756 APP[28317:60b] numberOfRowsInSection:1 -> 1
2017-07-14 10:13:22.759 APP[28317:60b] numberOfRowsInSection:2 -> 1
2017-07-14 10:13:22.768 APP[28317:60b] numberOfRowsInSection:3 -> 1
2017-07-14 10:13:22.772 APP[28317:60b] numberOfRowsInSection:4 -> 1
2017-07-14 10:13:22.775 APP[28317:60b] numberOfRowsInSection:5 -> 1
2017-07-14 10:13:22.838 APP[28317:60b] numberOfSectionsInTableView
-(void) loadDBData
{
NSLog(@"loadDBData");
NSString *entityName = nil;
switch (_tableView.tag) {
case 1:
entityName = NSStringFromClass([Vehicle class]);
break;
case 2:
entityName = NSStringFromClass([Driver class]);
break;
default:
entityName = NSStringFromClass([Zone class]);
break;
}
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName: entityName];
// Set the batch size to a suitable number.
// [fetchRequest setFetchBatchSize:5];
NSSortDescriptor *groupSort = [[NSSortDescriptor alloc] initWithKey:@"group.name" ascending:YES];
NSSortDescriptor *nameSort = nil;
switch (_tableView.tag) {
case 1:
nameSort = [[NSSortDescriptor alloc] initWithKey:@"vehicleDescription" ascending:YES];
break;
default:
nameSort = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
break;
}
NSSortDescriptor *groupSortID = [[NSSortDescriptor alloc] initWithKey:@"group.id_group" ascending:YES];
fetchRequest.sortDescriptors = @[groupSort, groupSortID, nameSort];
self.fechedResultController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:[DBController getDBController].managedObjectContext sectionNameKeyPath:@"group" cacheName:nil];
[self.fechedResultController setDelegate:self];
NSError *fetchingError = nil;
if([self.fechedResultController performFetch:&fetchingError])
{
NSLog(@"Successfully fetched.");
}
else
NSLog(@"Failed to fetch.");
}