Show common user interface elements from Apple TV in your native app using TVUIKit.

Posts under TVUIKit tag

6 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Memory Leak in Apple TV(tvOS 17.4)
I found a memory leak in tvOS 17.4, but it's not happening in tvOS 18.0 here is the code flow 1.I have controller inside which I have tableView which in turn contains a collectionview here I have passed self to tableViewcell as delegate and then from tableview cell I have passed self again as delegate to collectionViewcell, but memory is not released, because self is retained "I have passed self as weak every where still memory leak is happening only in tvOS 17.4 and below versions. but in 18.0 and above versions it's fine"
1
0
160
1w
tvOS: Search Keyboard Unresponsive After Dismissing Custom Controller with Embedded TVDigitEntryViewController
Description I'm developing a tvOS application where I utilize a UISearchController embedded within a UISearchContainerViewController for search functionality. In a particular flow, a custom view controller contains a TVDigitEntryViewController as a child, with its modalPresentationStyle set to .blurOverFullScreen. The issue arises when a user initiates the PIN entry but decides to cancel and return to the search interface without entering a PIN. Upon returning, the search keyboard is no longer visible, and attempts to focus or interact with it are unsuccessful. Steps to Reproduce Initialize and present a UISearchContainerViewController that contains a UISearchController with a results view controller. Within the search results, present a custom view controller containing TVDigitEntryViewController as a child, setting its modalPresentationStyle to .blurOverFullScreen. Dismiss the custom view controller without entering a PIN (e.g., by pressing the Menu button on the remote). Observe that upon returning to the search interface, the keyboard is missing, and focus interactions are unresponsive. Observed Behavior After dismissing the custom view controller with TVDigitEntryViewController, the search keyboard does not reappear, and the focus system seems to lose track of the search input field. Expected Behavior The search keyboard should remain visible and functional after dismissing the custom view controller, allowing users to continue their search without interruption. Additional Context I have reviewed the TVDigitEntryViewController documentation (developer.apple.com) and related discussions on the Apple Developer Forums but have not found a solution to this specific issue. Questions Has anyone encountered a similar issue or have insights into why the search keyboard becomes unresponsive after dismissing a .blurOverFullScreen modal with a child TVDigitEntryViewController? Are there recommended practices to ensure the search keyboard remains active and focusable after such modal presentations? Any guidance or suggestions would be greatly appreciated. Thank you!
3
0
217
3w
Controlling the focus order in a UICollectionView
I'm running into a problem with the focus order in my UICollectionView in my tvOS app. The layout of my app is outlined in the following diagram On the uppermost layer I have a UITableView, each cell containing a single UICollectionView that can contain a variable number of UICollectionViewCells. When the user swipes down, I want the left-most item in the next row down to be selected, as follows: I've been able to get this to work for the majority of cases. The exception is when the previously focused item extends to the length of the screen - in this case the next focused item isn't the leftmost item, but rather the center item, as follows. Using focus guides won't really fit the use case here since collection views are dynamically generated. I've found that there is a function in UICollectionViewDelegate, indexPathForPreferredFocusedView that should help here but it only seems to be called intermittedly, even though I have set remembersLastFocusedIndexPath on the collectionview to true. I can force it to be called by calling setNeedsFocusUpdate() but I can't figure out a good place to call it - shouldUpdateFocus is too early and didUpdateFocus is too late. Is there some way to constrain the focus area of a view to a certain subset of it's frame - for example, the left-most quarter of its width? Or does anyone know of some other solution to this problem?
1
0
292
Jan ’25
[tvOS 18][SwiftUI] Severe ScrollView Lag after Update
Hello, I've upgraded both of my Apple TVs to tvOS 18. Since then, my app developed with SwiftUI has become almost unusable due to severe lag, particularly when scrolling in a LazyVStack. On the A1625 (Apple TV HD), the lag can last up to 20 seconds, while on the A2843 (Apple TV 4K, 3rd generation, Wi-Fi + Ethernet), it’s about one second. I can consistently reproduce the issue with this minimal example: @main struct MyApp: App { var body: some Scene { WindowGroup { ScrollView { LazyVStack { ForEach(0..<1000) { nb in Button("Item \(nb)") {} } } } } } } Using Instruments, I found that the hang is related to this call: 389.00 ms 71,4 % 6.00 ms +[_UIFocusRegionEvaluator __regionsByEvaluatingOcclusionsForBaseRegions:occludingRegions:baseRegionsCanOccludeEachOther:inSnapshot:] Unfortunately, I can't attach the Instruments trace directly here, but you can download it from this link: https://drive.google.com/file/d/1sEIwXhr7_ajjRHZevCIW6jNOlPjaeU6L/view?usp=sharing Important notes: The same screen, when written in UIKit, runs smoothly on both devices. After performing a factory reset on the older device, the performance issue disappeared. However, as you can imagine, I’m already receiving complaints from users who are understandably unwilling to reset their devices. Does anyone know of a workaround until this is addressed by Apple?
3
1
861
Oct ’24
UICollectionView can't keep the focused row stick to the top
I'm creating a Netflix like app on tvOS, here is my compositional layout that I use with my collectionView. private func createLayout() -> UICollectionViewCompositionalLayout { return UICollectionViewCompositionalLayout { (section, _) -> NSCollectionLayoutSection? in // item let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1.0)) let item = NSCollectionLayoutItem(layoutSize: itemSize) item.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 10, bottom: 0, trailing: 10) // group let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1/5), heightDimension: .estimated(350)) let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitems: [item]) // section let section = NSCollectionLayoutSection(group: group) section.orthogonalScrollingBehavior = .groupPaging let headerSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), heightDimension: .estimated(UIFont(name: "MyFont", size: 36)!.lineHeight)) let sectionHeader = NSCollectionLayoutBoundarySupplementaryItem( layoutSize: headerSize, elementKind: "SectionHeader", alignment: .top) section.boundarySupplementaryItems = [sectionHeader] section.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 20, bottom: 30, trailing: 0) return section } } So: My collection view is composed by several row (that are the sections). Each section is composed by groups containing 1 item each. Each section can be scrolled horizontally. And you can scroll vertically to move from a section to an other. I'm expecting to have the following behavior when scrolling: Horizontal scrolling: Before focus shifts -------------------------- | vA vB vC vD vE | | [v1] v2 v3 v4 v5 | | vU vW vX vY vZ | -------------------------- After focus shifts -------------------------- | vA vB vC vD vE | | [v2] v3 v4 v5 v6 | | vU vW vX vY vZ | -------------------------- Vertical scroll: Before focus shifts -------------------------- | [vA] vB vC vD vE | | v1 v2 v3 v4 v5 | | vU vW vX vY vZ | -------------------------- After focus shifts -------------------------- | [v1] v2 v3 v4 v5 | | vU vW vX vY vZ | | vF vG vH vI vJ | -------------------------- Thanks to section.orthogonalScrollingBehavior = .groupPaging the horizontal scrolling is working as expected. (I've put 1 item per group to achieve this) But I'm going crazy with the vertical scroll, I'm not able to achieve it as expected, the focused section still centered verticaly on the screen ! What I'm getting: Before focus shifts -------------------------- | [vA] vB vC vD vE | | v1 v2 v3 v4 v5 | | vU vW vX vY vZ | -------------------------- After focus shifts -------------------------- | vA vB vC vD vE | | [v1] v2 v3 v4 v5 | | vU vW vX vY vZ | -------------------------- After an other focus shifts -------------------------- | v1 v2 v3 v4 v5 | | [vU] vW vX vY vZ | | vF vG vH vI vJ | -------------------------- I've tried to play with the didUpdateFocusIn function without success func collectionView(_ collectionView: UICollectionView, didUpdateFocusIn context: UICollectionViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) { if let nextFocusedItemIndexPath = context.nextFocusedIndexPath { let section = nextFocusedItemIndexPath.section let sectionIndexPath = IndexPath(item: 0, section: section) collectionView.scrollToItem(at: sectionIndexPath, at: .top, animated: true) } } The collectionview is behaving strangely when using the didUpdateFocusIn function and I feel it's not the good way to perform what I'm expecting... I've also try to play with the scrollViewWillEndDragging function without success func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: } Everything that I tried looks like a hack and I can't believe Apple has not plan something for this use case, which is in my sense a common use case....
1
0
680
Aug ’24
AVPlayerViewController (AppleTV) - Dolby (multi-channel audio) visualisation
We noticed that AVPlayerViewController does not always show the "Multi-channel" label in the audio setting in the player when playing a video asset with surround sound as an audio track. (see image) We only serve in the HLS master manifest a multichannel audio track, like this #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio_0",CHANNELS="6",NAME="Surround",LANGUAGE.... Different tvOS versions will give us different outcomes on whether or not the "multi-channel" label is shown DOES NOT SHOW (the label Multi-channel will not show) Model A1842 (tvOS v 17.5.1) Model A1625 (tvOS v 16.6) DOES SHOW (see image) Model A1625 (tvOS v 15.6) This gives us the impression that the label being shown depends on tvOS version.. Any reason why? This is an ideal way for the user to see that the audio track has surround..
0
1
692
Jul ’24