I'm displaying a modal uiviewcontroller in the normal fashion:
[self.navigationController presentModalViewController:self.lvc animated:YES];
//do stuff
and later on...
[self.navigationController dismissModalViewControllerAnimated:FALSE];
The problem is that //do stuff is too fast, and the dismiss call happens before the presentation call animation completes, which has the net effect of not dismissing the view at all. if i set the animation parameter to false, everything works, every time, or if //do stuff takes longer than the animation...
what to do? sleep? (ick), cancel the transition animation somehow?
not enough info? here's some more:
the point is, sometimes the worker thread finishes before the original modalviewcontroller animation completes, which causes problems when dismissmodalviewcontroller is called. In summary, if you call dismiss before the present animation completes, you cannot actually dismiss it. I'm filing a bug w/ apple atm.
And here's the proof testcase:
#import "ModalbugsViewController.h"
@implementation modalbugsViewController
@synthesize modal;
-(void)dismisser {
[self dismissModalViewControllerAnimated:TRUE];
}
-(void) sleeper:(NSNumber *) t{
[NSThread sleepForTimeInterval:[t floatValue]];
[self performSelectorOnMainThread:@selector(dismisser) withObject:NULL waitUntilDone:TRUE];
}
-(IBAction) shortClick:(id)sender {
[self presentModalViewController:self.modal animated:YES];
[NSThread detachNewThreadSelector:@selector(sleeper:) toTarget:self withObject:[NSNumber numberWithFloat:0.1f]];
}
-(IBAction) longClick:(id)sender {
[self presentModalViewController:self.modal animated:YES];
[NSThread detachNewThreadSelector:@selector(sleeper:) toTarget:self withObject:[NSNumber numberWithFloat:5.0f]];
}
- (void)dealloc {
[self.modal release];
[super dealloc];
}
@end