당신은 배열의 레코드 사용자 수에 따라 조건을 처리 manullay 수 있습니다. 다음은 나는 너에게 몇 가지 sa를주고있다.
Array의 레코드를 기반으로 셀의 rown 수를 반환합니다.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([jsonArray count] == 20) { // Only call the function if we have 20 results in the array OR maintain its counts based on your array counts.
if (indexPath.row == [localJsonArray count]) {
NSLog(@"Load More requested"); // Add a function here to add more data to your array and reload the content
} else {
NSLog(@"Normal cell selected"); // Add here your normal didSelectRowAtIndexPath code
}
} else {
NSLog(@"Normal cell selected with < 20 results"); // Add here your normal didSelectRowAtIndexPath code
}
}
:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if ([jsonArray count] < 20) //20 Will change based on your number of records as loop progresses.
{
return [self.localJsonArray count];
} else {
return [self.localJsonArray count] + 1;
}
}
는 이벤트 처리 유지하고 다른 사람과 추가 ROW 구별 배열에서 셀에 데이터를 입력하고 조건
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
ImageCell *cell = (ImageCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (indexPath.row != [localJsonArray count]) { // As long as we haven’t reached the +1 yet in the count, we populate the cell like normal
if (cell == nil) {
cell = [[[ImageCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
NSDictionary *itemAtIndex = (NSDictionary *)[self.localJsonArray objectAtIndex:indexPath.row];
[cell setData:itemAtIndex];
} // Ok, all done for filling the normal cells, next we probaply reach the +1 index, which doesn’t contain anything yet
if ([jsonArray count] == 20) { // Only call this if the array count is 25
if(indexPath.row == [localJsonArray count]) { // Here we check if we reached the end of the index, so the +1 row
if (cell == nil) {
cell = [[[ImageCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
// Reset previous content of the cell, I have these defined in a UITableCell subclass, change them where needed
cell.cellBackground.image = nil;
cell.titleLabel.text = nil;
// Here we create the ‘Load More Posts.’ cell
loadMore =[[UILabel alloc]initWithFrame: CGRectMake(0,0,362,73)];
loadMore.textColor = [UIColor blackColor];
loadMore.highlightedTextColor = [UIColor darkGrayColor];
loadMore.backgroundColor = [UIColor clearColor];
loadMore.font=[UIFont fontWithName:@"Verdana" size:20];
loadMore.textAlignment=UITextAlignmentCenter;
loadMore.font=[UIFont boldSystemFontOfSize:20];
[email protected]"Load More Posts...";
[cell addSubview:loadMore];
}
}
return cell;
}
그리고 마지막으로 확인
iOS 6 이상을 사용하는 경우 UIRefreshControl을 사용할 수 있습니다. 그것은 더 표준적인 방법입니다. – Midas
테이블 뷰에 바닥 글 추가 –