Hi all,
I'm trying to get an tableview to work with different custom cell xib's.
Based on the section it must become a different cell.
In the second section there are 2 buttons, 1 is to go to next category and 1 to go back to the main view.
Now when I tap these buttons once, it will take up to 10-15 seconds before it actually gets triggered.
If I tap twice it will go straight through.
There for I did put in a activity indicator. Just so the user knows it is doing something...
How can I solve this bad response ? It does not occure straight form the beginning.
Once I moved to second viewcontroller with also a table, and moved back, then this happens.
I'm using the following code:
----------
UPDATE
----------
At first I did it like this, calling the next view using transition.
Now I made segue's from all viewcontrollers to eachother with their own identifier, and call the segue by identifier, based on the reply of AxoNeuron, which actually saves a lot of typing and code
Triggering the performSegue from a static button, results that the app goes through straight away, but by the didSelectRowAtIndexPath it's waiting for something thats not there! :-/
The end of the function reached straight away, also after calling performSegue, but it's holding on the next viewcontroller's viewDidLoad. viewWillAppear and viewDidAppear don't get called before the 'timeout' and/or I just randomly tap somewhere randomly once
Found a simulair topic on stackoverflow, mentioning to use sender: nil for performSegueWithIdentifief, so that the tableview itself wont be included.
Ofcourse I did that straight away, but still having the same issue..
After playing around with settings of the segue, I found out that when I use the default segue 'Present Modally' and presentation as 'Full Screen' instead of 'Default' it looks like this is solved.
But after 2 times, the issue is back
p.s. updating to 10.10.4 and updating xcode at the moment.
-------------
SOLLUTION
-------------
since iOS8 it seems to be a bug in the tableViewDidSelectRow function.
Calling segues from this function's thread queue will cause a delay.
By forcing the segue to be triggered in the main queue will sove the issue:
I'm glad this is solved. Then I can finally roll-out the app.
I'm trying to get an tableview to work with different custom cell xib's.
Based on the section it must become a different cell.
In the second section there are 2 buttons, 1 is to go to next category and 1 to go back to the main view.
Now when I tap these buttons once, it will take up to 10-15 seconds before it actually gets triggered.
If I tap twice it will go straight through.
There for I did put in a activity indicator. Just so the user knows it is doing something...
How can I solve this bad response ? It does not occure straight form the beginning.
Once I moved to second viewcontroller with also a table, and moved back, then this happens.
I'm using the following code:
Code:
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
categoryItem *cell = [categoriesTable dequeueReusableCellWithIdentifier: @"catCell"];
if(!cell) {
[tableView registerNib: [UINib nibWithNibName: @"categoryCell" bundle: nil] forCellReuseIdentifier: @"catCell"];
cell = [tableView dequeueReusableCellWithIdentifier: @"catCell"];
}
if(indexPath.section == 0) {
[cell.theCategory setText: [theCategories objectAtIndex: indexPath.row]];
[cell.theImage setImage: [UIImage imageNamed: [NSString stringWithFormat: @"s%i.png",(int)[(NSNumber *)[theCategoriesID objectAtIndex: indexPath.row] integerValue]]]];
} else {
if(indexPath.row == 0) {
[cell.theImage setImage: [UIImage imageNamed: @"send.png"]];
[cell.theCategory setText: @"Send Audit"];
} else {
[cell.theImage setImage: [UIImage imageNamed: @"stop.png"]];
[cell.theCategory setText: @"Back to start"];
}
}
[cell setSelectionStyle: NO];
return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[categoryActivity setHidden: NO];
if(indexPath.section == 0) {
categoryDelegate->curCategory = (int)[(NSNumber *)[theCategoriesID objectAtIndex: indexPath.row] integerValue];
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *nextView = [mainStoryboard instantiateViewControllerWithIdentifier: @"criteriumView"];
nextView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController: nextView animated:YES completion:nil];
} else {
if(indexPath.row == 1) {
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *nextView = [mainStoryboard instantiateViewControllerWithIdentifier: @"mainView"];
nextView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController: nextView animated:YES completion:nil];
} else {
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *nextView = [mainStoryboard instantiateViewControllerWithIdentifier: @"sendView"];
nextView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController: nextView animated:YES completion:nil];
}
}
}
- (NSInteger)tableView: (UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if(section == 0)
return theCategories.count;
else
return 2;
}
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if (section == 0)
return CGFLOAT_MIN;
return 35.0f;
}
- (NSString*) tableView:(UITableView *) tableView titleForHeaderInSection:(NSInteger)section {
if (section == 0) {
return nil;
} else {
return @" ";
}
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *view = [[UIView alloc]init];
[view setAlpha:0.0F];
return view;
}
----------
UPDATE
----------
At first I did it like this, calling the next view using transition.
Code:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *nextView = [mainStoryboard instantiateViewControllerWithIdentifier: @"mainView"];
nextView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController: nextView animated:YES completion:nil];
Now I made segue's from all viewcontrollers to eachother with their own identifier, and call the segue by identifier, based on the reply of AxoNeuron, which actually saves a lot of typing and code
Code:
[self performSegueWithIdentifier: nextViewSegue sender: self];
Triggering the performSegue from a static button, results that the app goes through straight away, but by the didSelectRowAtIndexPath it's waiting for something thats not there! :-/
The end of the function reached straight away, also after calling performSegue, but it's holding on the next viewcontroller's viewDidLoad. viewWillAppear and viewDidAppear don't get called before the 'timeout' and/or I just randomly tap somewhere randomly once
Found a simulair topic on stackoverflow, mentioning to use sender: nil for performSegueWithIdentifief, so that the tableview itself wont be included.
Ofcourse I did that straight away, but still having the same issue..
After playing around with settings of the segue, I found out that when I use the default segue 'Present Modally' and presentation as 'Full Screen' instead of 'Default' it looks like this is solved.
But after 2 times, the issue is back
p.s. updating to 10.10.4 and updating xcode at the moment.
-------------
SOLLUTION
-------------
since iOS8 it seems to be a bug in the tableViewDidSelectRow function.
Calling segues from this function's thread queue will cause a delay.
By forcing the segue to be triggered in the main queue will sove the issue:
Code:
dispatch_async(dispatch_get_main_queue(), ^{
[self performSegueWithIdentifier: @"mySegueIdentifier" sender: nil];
});
I'm glad this is solved. Then I can finally roll-out the app.
Last edited: