如何在每次按下时实现触发不同操作的按钮?

时间:2012-07-30 04:17:48

标签: xcode uibutton

就像视频录制按钮一样。按下时启动,再次按下时停止。

一点指导会非常有帮助...... 提前谢谢!

1 个答案:

答案 0 :(得分:0)

对于显示播放/停止的切换按钮,以下内容将起作用...

-(IBAction) togglePlay:(id)sender{


        if (audioPlayer.playing) {

            [audioPlayer stop];
            [playButton setBackgroundImage:playSoundImage forState:UIControlStateNormal];

            //set image play

        }else{

            [audioPlayer play];
            [playButton setBackgroundImage:stopSoundImage forState:UIControlStateNormal];

        }


}