Reputation: 375
How can i automatically push my view controller to another view controller? I got this code in viewWillApear, when my Tabledata contains 1 item it need to push it directly to another view controller but it doesn't work
if ([DatainTable count] == 1) {
count.text = [NSString stringWithFormat:@"xxx"];
xViewController *scoreView = [[xViewController alloc]initWithNibName:@"xViewController" bundle:nil];
[scoreView.count setText:count.text];
[self.navigationController pushViewController:scoreView animated:YES];
}
i tried alot of other things but without success
Upvotes: 1
Views: 180
Reputation: 1684
Why would make the user sit through controllers pushing each other? Push scoreView not where you are pushing it right now, but in the controller before it, the one that pushes the controller which code you provided. Of course, only do it if [DatainTable count]
== 1 or whatever your condition is.
Upvotes: 0
Reputation: 13694
Instead of putting the code in viewWillAppear:
(where the actual pushing of the first view has not yet occurred), you should put it in viewDidAppear:
(which is run when the first view has finished pushing and you can do any further tasks such as pushing a further controller)
Upvotes: 1