我有四个UIbuttons水平排列,当用户只关注4个按钮中的一个时,我将展示一个包含一些信息的UIVIEw.
如何在不需要单击按钮的情况下执行 *** 作?
解决方法 您可以在其中一个按钮成为焦点视图时执行 *** 作.您可以为每个按钮分配一个标记,并使用聚焦按钮的标记来确定要采取的 *** 作.为了便于阅读,您可以为每个标记定义一个包含值的枚举.
enum FocusedbuttonTag: Int { case First // Substitute with names that correspond to button's Title/action case Second case Third case Fourth}overrIDe func dIDUpdateFocusInContext(context: UIFocusUpdateContext,withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) { super.dIDUpdateFocusInContext(context,withAnimationCoordinator: coordinator) guard let button = UIScreen.mainScreen().focusedVIEw as? UIbutton else { return } // Update your UIVIEw with the desired information based on the focused button switch button.tag { case FocusedbuttonTag.First.rawValue: ... // first button's action case FocusedbuttonTag.Second.rawValue: ... // second button's action case FocusedbuttonTag.Third.rawValue: ... // third button's action case FocusedbuttonTag.Fourth.rawValue: ... // fourth button's action default: break }}总结
以上是内存溢出为你收集整理的swift – 如何在按钮焦点上执行tvOS中的动作事件全部内容,希望文章能够帮你解决swift – 如何在按钮焦点上执行tvOS中的动作事件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)