“返回”时的自定义行为按下导航栏中的按钮
我知道您可以向 UINavigationBar 添加自定义“后退”按钮,但这样做会删除左侧锥形的现有按钮,如 在导航栏中按下后退按钮时会发生什么
有什么方法可以保留后退按钮的现有行为和外观,但也可以按下时通知?
基本上,我希望我的应用程序在触摸任何按钮时播放声音。我可以通过 UITabBarController 的委托来完成此操作,但 UINavgationBarController 的委托没有这样的功能。
I know that you can add a custom "back" button to a UINavigationBar, but doing so removes the existing button with the tapered left side, as described in What happens when back button is pressed in navigationBar
Is there any way to keep the existing behavior and look of the back button, but also be informed when it is pressed?
Basically, I want my app to play a sound whenever any button is touched. I can do it with UITabBarController via its delegate, but the delegate for UINavgationBarController has no such functionality.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是视图控制器消失的可能性。
无论哪种情况都会调用
viewWillDisappear:
方法。保留一个布尔标志。我们将其命名为 isAnyButtonClicked。并在单击任何按钮时设置isAnyButtonClicked = YES
。并重写viewWillDisappear:
方法,并在没有单击按钮时播放声音(即isAnyButtonClicked == NO
)。可能你的viewWillDisappear:
看起来像,The following are the possibilities for a View Controller to disappear.
Either case
viewWillDisappear:
method will be called. Keep a boolean flag. Lets name it isAnyButtonClicked. And setisAnyButtonClicked = YES
whenever any button is clicked. And override theviewWillDisappear:
method, and play the sound if no button is clicked(ie.,isAnyButtonClicked == NO
). Probably yourviewWillDisappear:
would look like,