0
当我主要的viewController是第一次点击,就开始显示演示(上重复)如下:停止编程循环
showingDemo = YES;
[self startDemo];
- (void)startDemo {
if (showingDemo) {
[self performSelector:@selector(stepone) withObject:nil afterDelay:1.5f];
[self performSelector:@selector(steptwo) withObject:nil afterDelay:2.0f];
[self performSelector:@selector(stepthree) withObject:nil afterDelay:3.8f];
[self performSelector:@selector(stepfour) withObject:nil afterDelay:4.3f];
[self performSelector:@selector(startDemo) withObject:nil afterDelay:5.6f];
}
}
当它被点击一次,我带来了新的视图控制器屏幕
showingDemo = NO;
[self.view addSubview:newView];
我以为这会阻止无限循环。
当用户返回到我的主要的viewController:
[newView.view removeFromSuperview];
并再次在屏幕上点击:
showingDemo = YES;
[self startDemo];
在测试我的应用程序,如果我点击快速反击(循环具有前有时间结束了,程序似乎要经过两次循环 - 之前的循环和新的循环 - 因此它看起来很奇怪,'step3'函数在'stepone'之前发生,等等。
任何人都知道一个更好的方法来停止循环我已经编程好了,所以当我以后再次启动它时,它不会运行多个循环,认为前一个没有完成?
非常感谢!
美丽。简单。真棒。谢谢! – RanLearns 2010-12-11 00:26:00