我以正常的方式顯示一個模式的UIViewController:modalviewcontroller動畫太快?
[self.navigationController presentModalViewController:self.lvc animated:YES];
//do stuff
後來就......
[self.navigationController dismissModalViewControllerAnimated:FALSE];
的問題是,//做的東西太快,而解僱通話在演示文稿調用動畫完成之前發生,這完全不影響視圖。如果我將動畫參數設置爲false,則每次都有效,或者如果//做的東西需要比動畫更長的時間...
該怎麼辦?睡覺? (ick),以某種方式取消過渡動畫?
沒有足夠的信息?這裏有更多一些:
的一點是,有時工作線程結束之前原modalviewcontroller 動畫完成,這會導致問題的時候dismissmodalviewcontroller被調用。總之,如果您在當前動畫完成之前致電解僱,您實際上不能解僱它。我正在申請一個bug /蘋果atm。
而這裏的證明測試用例:
#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
您需要提供更多關於您想要實現的信息。模態視圖是否使用了請稍候對話(正如Lyonanderson所建議的)?如果是這樣,如果操作完成時間很短,爲什麼還需要「請稍候」對話? – Jasarien