在UINavigationBar上点击播放声音
答
要做到这一点,你将需要更换新的电池通常的“返回”按钮,您的播放声音的代码:
但要注意,它不会像通常的“后退”按钮。它将是矩形。如果您有什么它看起来像往常一样“返回”按钮,执行它像cusom图像的自定义按钮(像往常一样“后退”按钮)
答
在你的流行方法,你可以通过播放声音:
- (IBAction)pop:(id)sender
{
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@”soundName” ofType:@”wav”];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath: soundPath], &soundID);
AudioServicesPlaySystemSound (soundID);
[soundPath release];
[self.navigationController popViewControllerAnimated:YES];
}
是不可能只是重写popViewControllerAnimated? – meggar 2011-12-21 03:43:52
我尝试覆盖通常的“后退”按钮 - 这是不可能的。要覆盖popViewControllerAnimated,您需要重写导航控制器类以使其能够满足您的需求。我认为在我的答案解决方案更容易 – SentineL 2011-12-21 03:49:17
适合我!谢谢 – meggar 2011-12-21 04:01:06