方法viewDidAppear和startTimerMethod的重复声明

时间:2014-07-12 13:20:12

标签: objective-c uistoryboardsegue

我试图为不同的视图控制器多次使用此代码但是我继续得到相同的错误。方法viewDidAppear的重复声明和方法startTimerMethod的重复声明。你能告诉我如何尽快解决这个问题。先感谢您 。

代码在这里

- (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(transitionView2) userInfo:nil repeats:NO];
}

- (void) transitionView2 {
    [self performSegueWithIdentifier:@"viewTransition2" sender:self];
}

1 个答案:

答案 0 :(得分:0)

只需删除以下三种方法,这两种方法已经宣告了两次 -

  - (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];
   }