tvos

How to move the focus from a button to another in tvOS?

时光总嘲笑我的痴心妄想 提交于 2019-12-07 05:49:45
问题 I'm new to tvOS. I would like to have a standard button that once is pressed, it moves the focus to another standard button, how can I do this (if it's possible of course)? 回答1: Start by overriding the preferredFocusedView in your viewController with a custom property: var myPreferredFocusedView:UIView? override var preferredFocusedView: UIView? { return myPreferredFocusedView:UIView } Then, in your button callback, set the myPreferredFocusedView to your next preferred button which should get

How to center UICollectionViewCell that was focused?

狂风中的少年 提交于 2019-12-07 05:17:39
问题 What I want to achieve is very simple: each time user focuses a collection view cell, I want to make the focused cell horizontally centered. It seems like my current approach doesn't work at all. func collectionView(collectionView: UICollectionView, didUpdateFocusInContext context: UICollectionViewFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) { guard collectionView === self.categoryCollectionView else { return } guard let indexPath = context

Setting up Apple TV video JavaScript

烈酒焚心 提交于 2019-12-06 13:53:53
I have a simple function that will launch the player that handles video playback for the Apple TV function launchPlayer() { var player = new Player(); var playlist = new Playlist(); var mediaItem = new MediaItem("video", "http://localhost:9001/videos/nsoperations.mp4"); player.playlist = playlist; player.playlist.push(mediaItem); player.present(); } According to the Player Documentation , all I needed to play a video back is a player, a playlist (docs) , and a media item (docs) . I've got all those, but when running my code, I get an error: Unable to simultaneously satisfy constraints. To my

How do I get a UIButton press to work in a UICollectionViewCell in Swift?

别说谁变了你拦得住时间么 提交于 2019-12-06 12:58:46
So this is a tvOS project in Swift. I have a custom UICollectionViewCell with a button as one of its subviews. I add a target to the button to allow it to interpret clicks. Here's a simplified version of the relevant code class CustomCell: UICollectionViewCell { var button:UIButton! override init(frame: CGRect) { super.init(frame: frame) button = UIButton(...) // Button is initialized with a frame button.userInteractionEnabled = true button.enabled = true button.addTarget(self, action: "pressed:", forControlEvents: .PrimaryActionTriggered) contentView.addSubview(button) } func pressed(sender:

AVPlayerViewController inside a view is not showing the playback controls

时光总嘲笑我的痴心妄想 提交于 2019-12-06 10:29:51
问题 I am working with apple tv. I have a UIView inside my UIViewController. I am adding AVPlayerViewController as subview of my UIView. UIView's frame is CGRect(x: 50, y: 50, width: 1344, height: 756). I am setting AVPlayerViewController frame equals to my UIView's frame. Issue is that video plays fine in its frame but the controls like pause, play, forward etc. are hidden and not working. But when I set frame as CGRect(x: 0, y: 0, width: 1920, height: 1080), controls are visible and working. My

Unable to load LCR image in tvOS apps

回眸只為那壹抹淺笑 提交于 2019-12-06 10:10:50
I am trying to load LCR image in UIImageView using "contentsOfFile" method as described in apple document but I am getting error with nil image. Can anyone please confirm how we can load LCR images from server? Code I am using: UIImage(contentsOfFile: "LCR file url") Error I am getting in console: BOMStorage BOMStorageOpenWithSys(const char , Boolean, BomSys ): can't open: '/LCR file url' No such file or directory One thing I noticed is it adds "/" in front of my actual url. I think its because its looking for files in local storage. Does anyone know whats the solution of it? I even tried to

How to get Parallax Effect on UIButton in tvOS?

时光总嘲笑我的痴心妄想 提交于 2019-12-06 07:13:07
I'm trying to make some UIButtons in a UIView for a tvOS app but have been unable to get them to display the new parallax effect in the simulator. I successfully set up a TV image stack in images.xcassets called "startReadingButton" and my buttons load with the file, but they do not display the shiny parallax effect when swiping around on the remote in the simulator. Here is how I am loading my UIButtons: for button in 1...5 { let image = UIImage(named: "startReadingButton") let newButton = UIButton(type: .Custom) newButton.frame = buttonRects[button - 1] newButton.setBackgroundImage(image,

How to detect bumps via Apple TV Siri Remote

删除回忆录丶 提交于 2019-12-06 07:12:18
问题 I'm unable to find any documentation relating to right and left bumps on the new Apple TV Siri Remote. You can see this in action at 1:00 of this video, Hands On: Apple TV 2015 Bluetooth Touch, Motion & Siri Remote. Remote and Interactions mentions positional taps, but these bumps are triggered by the accelerometer, suggested by the video. Are these bumps actually positional taps? How can I detect left and right bumps ? 回答1: Tapping (without clicking the physical button) on the edges of the

Sprite Kit game crashes on Game Over on tvOS 9.1 and iOS 9.2

这一生的挚爱 提交于 2019-12-06 06:23:56
I have a Sprite Kit game that is crashing when the game is over. This happening on the tvOS 9.1 and iOS 9.2. Before, I had it running on iOS 9.1 without crashing. It seems to be an OpenGL issue, but when I search the function in Xcode, it doesn't come up with anything. Unfortunately, the error is not consistent in appearing in the console. Here's the error: Jet: draw_indexed: indexType must be 'unsigned_int' or 'unsigned_short' Assertion failed: (indexType == jet_component_type_unsigned_int || indexType == jet_component_type_unsigned_short), function draw_indexed, file /BuildRoot/Library

CLLocationManager and tvOS - RequestWhenInUseAuthorization() not prompting

↘锁芯ラ 提交于 2019-12-06 05:15:35
I seem to be having a little trouble getting tvOS to prompt the user for location data authorization. I literally copied and pasted working code from iOS and it seems to not be prompting the user. I am using the code listed below as well as the NSLocationWhenInUseUsageDescription key with a string value. The only difference in the api that I see is on iOS it uses startupdatinglocation() and on tvOS it uses requestLocation() (similar to watchOS) I've stepped through the problem and it is infact hitting requestWhenInUseAuthorization() but simply doesn't prompt the user. Any idea what is going on