非常感谢您的回复。在这里,我实现了“NSTimer”概念,而不是使用“PerformSelector:afterDelay”。这是代码,
timer = [NSTimer scheduledTimerWithTimeInterval: 5.0
target: self
selector: @selector(goToNextView)
userInfo: nil
repeats: NO];
// here i have set the time interval of '5.0' and after that taking into next view.
-(void)goToNextView
{
newtest15 *nt=[[newtest15 alloc]init];
[self.navigationController pushViewController:nt animated:YES];
}
我在工具栏上有一个按钮,它也用于导航到下一个视图。
-(IBAction)btn:(id)sender{
if ( [timer isValid])
{
[timer invalidate], timer=nil;
}
newtest15 *nt=[[newtest15 alloc]init];
[self.navigationController pushViewController:nt animated:YES];
}
/* here, when the user wants to move to next view before the time interval of '5', and presses the button at the bottom, this action will be performed, it will invalidate the timer and navigate to the next view*/