Reputation: 2037
is there a way to for a UITableView to show the begin of the results using reloadData instead of showing the same position as before it's called?
Code:
-(void)orderResult{
FMDatabase *db = [DatabaseManager openDatabase:@QRDATABASE];
NSString *queryCounter = [NSString stringWithFormat:@"select count(*) as count from %@", self.appDelegate.query];
FMResultSet *rsCount = [db executeQuery:queryCounter];
[rsCount next];
self.rowCounter = [rsCount intForColumn:@"count"];
if (([rule isEqualToString:@""] )|| (rule == nil)) {
rule = @"dist";
}
NSLog(@"initWithStyle: self.rowCounter = %i", self.rowCounter);
FMResultSet *rs = [db executeQuery:queryTest];
results = [[NSMutableArray alloc]init];
while ([rs next]){
NSMutableArray *aRS = [[NSMutableArray alloc] init];
[aRS addObject:[rs stringForColumn:@"nome"]];
[aRS addObject:[rs stringForColumn:@"dist"]];
NSLog(@" while ([rs next]): %@ - %@",[aRS objectAtIndex:0], [aRS objectAtIndex:1]);
[results addObject:aRS];
[aRS release];
}
[db release];
}
-(IBAction)azOrg{
NSLog(@"azOrg");
rule = @"nome";
[self orderResult];
[table reloadData];
}
Regards!
Upvotes: 0
Views: 189
Reputation: 3762
You do know about the sdk documentation, right?
Check out UITableView's - (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated method.
Upvotes: 1
Reputation: 57179
You can not by using realodData
but you can by using scrollToRowAtIndexPath:atScrollPosition:animated:
immediately afterwards.
-(IBAction)azOrg{
NSLog(@"azOrg");
rule = @"nome";
[self orderResult];
[table reloadData];
[table scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]
atScrollPosition:UITableViewScrollPositionTop
animated:YES]; //Change to NO if you do not want it to animate
}
Upvotes: 1