下面,供大家參考代碼中使用YourJsonArray。
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
NSInteger numOfSections = 0;
if ([searchArray count])
{
self.tableView = UITableViewCellSeparatorStyleSingleLine;
numOfSections = 1;
self.tableView.backgroundView = nil;
}
else{
if ([results count])
{
self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
numOfSections = 1;
self.tableView.backgroundView = nil;
}
else
{
self.noDataLabel.text = @"No Data Available";
self.noDataLabel.textColor = [UIColor blackColor];
self.noDataLabel.textAlignment = NSTextAlignmentCenter;
self.tableView.backgroundView = self.noDataLabel;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}
}
return numOfSections;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSUInteger rows =0;
if(self.searchBar.text.length > 0){
rows = [searchArray count];
return rows;
}
else{
rows = results.count;
}
DLog(@"%ld",rows);
return rows;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
TableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"TableViewCell"];
if((self.searchBar.text.length > 0)){
sObject * searchObj = [searchArray objectAtIndex:indexPath.section] ;
[cell setData:searchObj];
}
else if([results count] == 0){
return cell;
}
else {
sObject * ordObj = [results objectAtIndex:indexPath.row];
[cell setData:ordObj];
}
return cell;
}
,我添加以下線路發送Json
請求之前
self.noDataLabel.text = @".. Fetching Data Please Wait ..";
llyas你檢查填充表前陣算什麼?你正在重新加載主線程上的表嗎?有許多事情可以檢查和解決,使用斷點來調試。 –
你可以上傳一些代碼更清晰 –
Tushar,是的,我已經檢查了你上面寫的東西,一切都如預期。 –