0

I am at work and don't have the code to hand right now but will post it later, just wanted to see if I could get any answers before I got home.

Basically, I have a tableViewController (view1) with a button on it which pushes to another tableViewController (view2).

the button on view1 checks if the information needed to populate the table on view2 is available. if it is, great, the segue can be performed; if it isn't then the data is stored in the background and then the segue is done.

this does work, but the issue i have is for the 2nd instance, when the data isnt previously saved and the button then saves it, the segue is performed before all of the data is saved in the background, so the table only shows a few records. going back and then pressing the button again solves this as the data has had more time to save and so the table in view2 is up to date.

what i want to do is either stop the segue from happening until all data is saved OR perform the segue and as each record is saved, update the table, so the user can see data is being generated.

i hope that makes some sense!

i can provide code later is needs be.

any suggestions would be great.

thanks

4

2 回答 2

0

在这种情况下,您应该创建一个从第一个表视图控制器到第二个的 segue。然后,一旦您成功保存了数据,您就可以像这样执行您的 segue

[self performSegueWithIdentifier:@"segueId" sender:self];

您可以在此处找到更多详细信息:如何在 iOS 5 中执行与用户输入无关的转场?

于 2013-09-05T08:56:57.407 回答
0
NSBlockOperation* performSeque = [NSBlockOperation blockOperatioWithBlock:^(){
    [self performSegueWithIdentifier:@"segueId" sender:self];
}];
[performSeque addDependency: [SaveOperation saveOperation]];
[[NSOperationQueue mainQueue] addOperation: performSeque];

您的sequ将在您的保存操作结束后立即执行。

于 2013-09-05T09:38:51.283 回答