在我的应用程序中,我显示项目的。我的JSON
供稿包含50个项目,但首先我想显示25,当用户向下滚动到最后一行时,需要加载更多项目。检测最后一行并添加一个
我做:
下载JSON
饲料;
NSString *jsonString = [NSString
stringWithContentsOfURL:[NSURL URLWithString:xmlDataUrl]
encoding:NSStringEncodingConversionAllowLossy
error:nil];
SBJSON *parser = [[SBJSON alloc] init];
NSDictionary *results = [parser objectWithString:jsonString error:nil];
parser = nil;
[self setTableData:[results objectForKey:@"feed"]];
//
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
//
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
//return [tableData count];
return 25;
}
,并检测最后一行:
if(indexPath.row == [self.tableData count] - 1)
{
NSLog(@"Last Row");
}
但它没有检测到最后一排。这是因为它下载的JSON包含超过25行?
而我怎么可以添加一个新的行就像[self.tableDate count] +1;
可能吗?
如果我回来[tableData count];
它的检测的最后一排,但行已经填补了100%我需要显示25/50比+1
您将无法添加行,因为您将25代码硬编码为该部分中的行数。 – 2012-04-13 20:57:54
我可以做; 'return [tableData count];'然后它会下载显示所有的项目,我可以设置一个最大和以后的+1? – Jones 2012-04-13 21:01:30