I have in my project different code which is responsible for the blur effect in my app. In tvOS 13 this worked fine but in tvOS 14 I have to remove the code otherwise the app will crash. What exactly do I have to change in the code to make it run on tvOS 14. Thanks for the help.
private func sharedSetup(effect: UIBlurEffect, radius: CGFloat = 90) {			
let UICustomBlurEffect = NSClassFromString("_UICustomBlurEffect") as! UIBlurEffect.Type
let raw = effect.value(forKey: "_style") as! Int
let style = UIBlurEffect.Style(rawValue: raw)!
let effect = UICustomBlurEffect.init(style: style)						
effect.setValue(1.0, forKey: "scale")		
effect.setValue(radius, forKey: "blurRadius")			
effect.setValue(UIColor.clear, forKey: "colorTint")
self.blurEffect = effect	
}
Post not yet marked as solved
Hi,
I'm having an issue with TVCollectionViewFullScreenLayout. The requirement is that a user can pick from a collection view of items which then presents a new ViewController with a UICollectionView using TVCollectionViewFullScreenLayout populated with cells derived from TVCollectionViewFullScreenCell, with the initial position set to the same item the user selected.
Calling collectionView.scrollToItemAt initially works but then it snaps back one position to the previous cell. Simply adding one to the index position leaves the user with an ugly animation as the view loads and then scrolls to the correct position.
I investigated the .centerIndexPath property but this is get only.
An example of the correct behaviour can be found in the TV app when selecting a title from a horizontal list of suggestions. The view that is presented starts with the item the user selected.
What follows is about tvOS 15 but may also apply to iOS 15.
Our app may display several types of UICollectionView cells and it depends on the content sent by our backend. Prior to tvOS 15, we used to lazily instantiate UICollectionView cell registrations when needed for the first time while building a UICollectionViewDiffableDataSource. Eventually, each cell registration is only instantiated once (or never).
Now tvOS 15 throws an exception when doing so, pretending to prevent the app from creating a new cell registration each time. And it does not care whether it's actually a new cell registration each time or one that is lazily instantiated once.
Here is the exception:
*** Assertion failure in -[UICollectionView dequeueConfiguredReusableCellWithRegistration:forIndexPath:item:], UICollectionView.m:7413
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempted to dequeue a cell using a registration that was created inside -collectionView:cellForItemAtIndexPath: or inside a UICollectionViewDiffableDataSource cell provider. Creating a new registration each time a cell is requested will prevent reuse and cause created cells to remain inaccessible in memory for the lifetime of the collection view. Registrations should be created up front and reused. Registration: <UICollectionViewCellRegistration: 0x6000000f8c60>'
I understand the concern but lazy instantiation is a thing and it should not be for forbidden for the sake of best practices that are not related to it. In my humble opinion, this assert should be removed and apps should be allowed to create cell registrations on the fly.
On tvOS you can choose Settings > Accessibility > Display > Focus Style > High Contrast to have teasers highlighted by a white border when focused:
However, I cannot find out how to use this feature on my own custom views. It seems that only TVPosterView makes use of this High Contrast accessibility setting. I'd like to be able to show such a frame on my custom views if this setting is enabled but I cannot find how to check if it's enabled.
None of the bools listed on https://developer.apple.com/documentation/uikit/uiaccessibility under Capabilities (like isVoiceOverRunning, isGuidedAccessEnabled, isReduceTransparencyEnabled, etc.) seems to refer to this Focus Style setting.
Can anybody point me in the right direction?
How do I check in code whether Focus Style is set to High Contrast?
How do I get the High Contrast frame on non-TVPosterView views?
I would like to click an element without user input. I see it's possible in XCUIElement which is a part of the XCTest framework to ensure things are working correctly, and I'm aware of various other testing frameworks that support E2E testing with simulated clicks. But is it possible to trigger this in production outside of testing? E.g. How app remotes work for a TV - pressing a button on the app will move right, left, or click an object on the TV (only remove the TV from this question and have it target the OS it's running on)
Post not yet marked as solved
Based on documentation, I would assume item scanning in Accessibility mode's Switch Control utilizes the underlying API - Focus-based Navigation from UI Kit (please correct me if I'm wrong). Where is the documentation for the other type of scanning it shows in the above link, point scanning? Thanks.
Post not yet marked as solved
I'm working on TVOS with new Remote and wanted to change the behavior of UIPress.PressType.leftArrow but couldn't found a solution so far.
Here is my testing code to disable the buttons, but the buttons are still working
Please, advise me to solve the problem
class MyScrollView: UIScrollView {
override var canBecomeFocused: Bool { true }
override init(frame: CGRect) {
super.init(frame: frame)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
print("\(type(of: self))::\(#function)")
}
override func pressesEnded(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
print("\(type(of: self))::\(#function)")
}
override func pressesCancelled(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
print("\(type(of: self))::\(#function)")
}
}
class ContainerView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
print("\(type(of: self))::\(#function)")
}
override func pressesEnded(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
print("\(type(of: self))::\(#function)")
}
override func pressesCancelled(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
print("\(type(of: self))::\(#function)")
}
}
class ViewController: UIViewController {
let scrollView = MyScrollView()
let contentView = ContainerView()
override func viewDidLoad() {
super.viewDidLoad()
// // Do any additional setup after loading the view.
scrollView.translatesAutoresizingMaskIntoConstraints = false
contentView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(scrollView)
NSLayoutConstraint.activate([
scrollView.leftAnchor.constraint(equalTo: self.view.leftAnchor, constant: 5),
scrollView.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: 5),
scrollView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor),
scrollView.heightAnchor.constraint(equalToConstant: 100)
])
scrollView.addSubview(contentView)
NSLayoutConstraint.activate([
contentView.topAnchor.constraint(equalTo: scrollView.topAnchor),
contentView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor),
contentView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor),
contentView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor),
contentView.heightAnchor.constraint(equalTo: scrollView.heightAnchor),
contentView.widthAnchor.constraint(equalToConstant: 6400)
])
contentView.backgroundColor = UIColor.red.withAlphaComponent(0.5)
scrollView.panGestureRecognizer.allowedTouchTypes = [
NSNumber(value: UITouch.TouchType.indirect.rawValue)
]
scrollView.panGestureRecognizer.allowedPressTypes = []
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
scrollView.contentInset = UIEdgeInsets(top: 0,
left: scrollView.bounds.width / 2,
bottom: 0,
right: scrollView.bounds.width / 2)
}
}
Post not yet marked as solved
I am attempting to detect changes of a UISlider value using the observer option but I am not getting any output.
Selected parts of code here
class MainViewController: UIViewController {
@IBOutlet weak var speedSlider: UISlider!
var speedSliderObserver: NSKeyValueObservation?
override func viewDidLoad() {
super.viewDidLoad()
setSettings()
}
func setSettings() {
speedSliderObserver = speedSlider.observe(.value, options: [.old, .new]) {
object, change in
print("speedSlider from: (change.oldValue!), to: (change.newValue!)")
}
}
Am I using observe correctly or is there some other way?
Post not yet marked as solved
how do I put the app i am developing on my apple th for testing?my apple tv is the latest 4K model.
Post not yet marked as solved
Hi!
I searched around but could not find any recent references on AppleTV planning to support HTML/Webview.
Does anyone have any updates about this, if Apple is planning to add support to HTML/WKWebView in the near future?
Thanks!