I have a UITableViewController which, when a cell is clicked, I want the controller to pop up itself, and then the controller that it pops up, insert another view controller on the stack.
I call this method because popped-to viewController is a delegate of tableViewController
Currently, I call this method with a delay on it, because otherwise everything becomes littered, waiting for the animation to finish. The implementation of this method seems a bit hacked and it seems to me that it will fail if one of the devices does not pop up at the expected wait time that I gave it.
Here are some of the code:
//**** code in my tableViewController ***// [self.navigationController popViewControllerAnimated:YES]; [self.delegate cellPressedInTableViewControllerWithCalculationsModel:(id)anArgmentMyDelegateMethodTakes]; // **** Code in the viewController being popped to ****// //CalculationsViewController is a subclass of UIViewController CalculationsViewController *calcViewController = [[CalculationsViewController alloc] init]; //some customization code would go her [self.navigationController performSelector:@selector(pushViewController:animated:) withObject:calcViewController afterDelay:0.75]; //this seems like the arbitrary part, the 0.75 second delay. [calcViewController release];
There seems to be a better way to pop / skip delegation, which will be performed after the animation finishes. It seems to me that waiting time seems to be the cause of unexpected problems.
I also tried using:
performSelectorOnMainThread:withObject:waitUntilDone
But the code just executes immediately, and the view hierarchy is screwed up.
I also looked at this question: The issue of delegation and it got me so far, but I'm curious to find out if there is a better way to accomplish such a task, Thank you.
edit: I also tried to wrap the method in an instance of NSInvocation, and I could not get it to coordinate the method call until the animation ended without arbitrarily setting a delay
ios objective-c iphone
Saamjb
source share