我希望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];
}
有人可以告诉我怎么做?
答案 0 :(得分:2)
替换 [self displayviewsAction:sender];
<强>与强>
[self performSelector:@selector(displayviewsAction) withObject:nil afterDelay:2.0]; // 2 seconds