0
在playpauseAction
方法執行它會播放音頻文件以及加載多個viewcontrollers
如何檢查是否audioplayer被暫停,同時加載多個viewcontrollers
-(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.timer = [NSTimer scheduledTimerWithTimeInterval:11 target:self selector:@selector(displayviewsAction:) userInfo:nil repeats:NO];
}
}
在加載這些view controllers
只想在每一個viewcontroller
,如果audioplayer
檢查暫停然後invalidate timer
如果沒有則繼續viewcontroller
裝載有NSTimer
- (void)displayviewsAction:(id)sender
{
FirstViewController *viewController = [[FirstViewController alloc] init];
viewController.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:viewController.view];
[self.view addSubview:toolbar];
if
([audioPlayer pause]){
[timer invalidate];
} else {
self.timer = [NSTimer scheduledTimerWithTimeInterval:23 target:self selector:@selector(secondViewController) userInfo:nil repeats:NO];
}
[viewController release];
}
我的問題是當我在displayviewAction
方法中添加if語句時,它給我的紅色警告信息是statement requires expression of scalar type (void invalid)
。
但是if statement
在playpauseAction
工作正常。
爲什麼if statement
的displayviewAction
正在發出紅色警告消息。