내 앱에서 총 80,000 개의 텍스트 "이름"이있는 NSMutableArray를로드하려고하는데 완벽하게 작동하지만 전체 스크롤을 스크롤 할 때 (부드럽 지 않은 스크롤이 아님) 지연됩니다.
따라서 UITableView의 표시되는 셀에만 내용을로드하는 방법을 찾고 있습니다 (비동기 적으로).
이것은 내 현재 코드입니다.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1; //count of section
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// return [[copyGenericDetails valueForKey:@"name"]count]; //count number of row from counting array hear cataGorry is An Array
return [[bigArray valueForKey:@"Name"]count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *MyIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:MyIdentifier];
}
cell.textLabel.text=[[bigArray valueForKey:@"Name"] objectAtIndex:indexPath.row];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 40;
}
이 목록의 스크롤을 도와주세요.
bigArray가 NSArray와 같은 내용이라고 가정하면 다음 줄이됩니다.
cell.textLabel.text=[[bigArray valueForKey:@"Name"] objectAtIndex:indexPath.row];
속도를 늦추는 것일 수도 있습니다. 는 [bigArray valueForKey:@"Name"]
모두 80,000 항목이 검사되도록하고, valueForKey를 얻을 및 저장. 그런 다음 올바른 행을 선택해야합니다. 나는 그들을 돌릴 것입니다.
cell.textLabel.text=[[bigArray objectAtIndex:indexPath.row] valueForKey:@"Name"];
이렇게하면 80,0000 개 항목을 조회하고 하나의 항목에 대해서만 Name 속성을 가져옵니다. 마찬가지로:
return [[bigArray valueForKey:@"Name"]count];
다음으로 대체 할 수 있습니다.
return [bigArray count];
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다