通过UIButton加载UIViewControllers并具有延迟功能

时间:2012-02-12 20:02:17

标签: iphone

我希望UIButton playpauseAction加载UIViewController有一些延迟,可能是NSTimer

-(void)playpauseAction:(id)sender 
{

  if  

  ([audioPlayer isPlaying]){

 [sender setImage:[UIImage imageNamed:@"play.png"] forState:UIControlStateSelected];

      [audioPlayer pause];

  } else {

 [sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal];

      [audioPlayer play];

      [self displayviewsAction:sender];


  }   

}


- (void)displayviewsAction:(id)sender
{   
   PageOneViewController *viewController = [[PageOneViewController alloc] init];

viewController.view.frame = CGRectMake(0, 0, 320, 480);

   [self.view addSubview:viewController.view];

  [self.view addSubview:toolbar];

[viewController release];
}

有人可以告诉我怎么做?

1 个答案:

答案 0 :(得分:2)

替换 [self displayviewsAction:sender];

<强>与

[self performSelector:@selector(displayviewsAction) withObject:nil afterDelay:2.0]; // 2 seconds