我正在尝试在多个视图控制器上使用Nstimer视图转换,但如果我复制并粘贴它,我会收到错误说明方法的重复声明。我该如何解决?请在你的回答中解释如何做到这一点。我从这个链接中找到了如何做到这一点。
http://x-code-tutorials.com/2013/06/19/nstimer-trigger-uiviewcontroller-transition/
- (void)viewDidAppear:(BOOL)animated {
[self startTimerMethod];
}
- (void) startTimerMethod {
transitionTimer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(transitionView) userInfo:nil repeats:NO];
}
- (void) transitionView {
[self performSegueWithIdentifier:@"viewTransition" sender:self];
}
- (void)viewDidAppear:(BOOL)animated {
[self startTimerMethod];
}
- (void) startTimerMethod {
transitionTimer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(transitionView) userInfo:nil repeats:NO];
}
- (void) transitionView {
[self performSegueWithIdentifier:@"viewTransition" sender:self];
}
答案 0 :(得分:0)
您可以将以下三种方法复制并粘贴两次,让它定义或声明单次: -
-(void)viewDidAppear:(BOOL)animated
-(void) startTimerMethod
-(void) transitionView