[英]UIImageView not gets Focused on tvOS
I have the following UIViewController
which i am doing in story board. 我有以下
UIViewController
,我在故事板上做。
The problem i am facing here is that when i try to swipe right on tv remote my UIImageView
does not get any focus. 我面临的问题是,当我尝试在电视遥控器上向右滑动时,我的
UIImageView
没有得到任何关注。 Infact no focus event happen, it try to put some logs in 实际上没有焦点事件发生,它试图放入一些日志
override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator)
but there is no focus event updated. 但没有更新焦点事件。 Earlier i have
UIImageView
directly added on self.view
in storyboard but i read somewhere the UIImageView
itself is not focusable so i put my UIImageView
inside another UIView
, but it still does not gets any focus. 之前我在故事板中直接在
self.view
上添加了UIImageView
,但我在某处读到了UIImageView
本身不可聚焦,所以我把我的UIImageView
放在另一个UIView
,但它仍然没有得到任何关注。 I have aligned top edges of UIView
which contains UIImageView
and UITextView
. 我已经对齐了包含
UIImageView
和UITextView
的UIView
顶部边缘。
Any help will be highly appreciated 任何帮助将受到高度赞赏
On a side note i also tried to do with UIFocusGuide but that didn't work also. 另外,我还尝试使用UIFocusGuide,但这也不起作用。 I think i don't need to use UIFocusGuide because it a basic right swipe focus thing.
我想我不需要使用UIFocusGuide,因为它是一个基本的右滑动焦点的东西。
UIImageView
is not by default focusable, and will not get focus effect, you can do two things to make it focusable. UIImageView
默认情况下不是可聚焦的,并且不会获得焦点效果,你可以做两件事来使它具有焦点。
UIImageView
and in subclass override canBecameFocused
and return YES
, and then override didUpdateFoucsInContext
and update appearance for focus state, like if focus make it bigger or change color etc. UIImageView
和子类覆盖canBecameFocused
并返回YES
,然后覆盖didUpdateFoucsInContext
并更新焦点状态的外观,如焦点使其变大或更改颜色等。 imageView.adjustImageWhenAncestorFocused = YES
also set clipToBounds = NO
on superview
imageView.adjustImageWhenAncestorFocused = YES
还设置clipToBounds = NO
上superview
So In your case as you are adding imageView to a view then that view should return YES/True from canBecameFocused. 因此,在您将viewView添加到视图的情况下,该视图应该从canBecameFocused返回YES / True。
@C_X is right. @C_X是对的。 The most important thing is that if
UIImageView
is added to self.view
then don't forget to subclass self.view
and override the canBecameFofused
method. 最重要的是,如果
UIImageView
添加到self.view
然后不要忘记继承self.view
并重写canBecameFofused
方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.