我正在编写一个使用MPMoviePlayerController播放网址的应用.该应用程序在后台运行,使用airplay也可以使用ATV,macmini使用airserver和XBMC.该URL是本地网络上的电影文件.我理解的方式是手机没有做任何繁重的工作,只是将网址传递给苹果电视,只要网址指向AppleTV支持的媒体,它就会播放.
我遇到的问题是苹果电视必须积极地ping通iphone并保持wifi有效,因为电池寿命非常严重.播放一部平均大小的电影会使iPhone 3GS的电池续航时间缩短约2/3,而iPhone 4S的电池续航时间则为1/2.
如果我正在使用空中服务器在mac mini上玩,那么手机上的电池寿命就会降低,就像手机背景并没有播放任何东西一样.我注意到,如果我停止在iPhone上的wifi,那么电影将继续在Mac mini上播放,但在ATV上停止约30秒.我猜测ATV一直在推出一个事件,说它正在播放,如果没有收到OK,那么它就会停止播放.
有什么我做错了吗?让其他人使用手机中的airplay体验相同的电量消耗吗?我试过别人的应用程序,它也做了同样的事情.
如何在tvOS中打开游戏中心排行榜?我已将此代码用于我的iPhone游戏,tvOS上没有"leaderboardIdentifier".
我计划在AppleTV上使用相同的排行榜(这将是同一个游戏).
非常感谢你的帮助,Stefan
@IBAction func handleGameCenter(sender: UIButton) {
let gcViewController = GKGameCenterViewController()
gcViewController.viewState = GKGameCenterViewControllerState.Leaderboards
gcViewController.leaderboardIdentifier = gamePrefix + "Leaderboard"
gcViewController.gameCenterDelegate = self
// Show leaderboard
self.presentViewController(gcViewController, animated: true, completion: nil)
}
func gameCenterViewControllerDidFinish(gameCenterViewController: GKGameCenterViewController) {
gameCenterViewController.dismissViewControllerAnimated(true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud) 是否有可能UIView成为焦点?或者我应该只UIButton为所有可能的视图使用自定义?
我试图覆盖canBecomeFocused但没有发生任何事情.
有没有办法禁用自动滚动UICollectionView时单元格聚焦?我想在聚焦时手动调整单元格的内容偏移量.
我不想更新内容偏移量:
- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context
withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator
{
[coordinator addCoordinatedAnimations:^
{
[UIView animateWithDuration:[UIView inheritedAnimationDuration]
animations:^
{
// Move next focused cell.
if ([context.nextFocusedView isKindOfClass:[YBZEventCollectionViewCell class]])
{
UICollectionViewCell *cell = (UICollectionViewCell *)context.nextFocusedView;
CGPoint offset = CGPointMake(CGRectGetMinX(cell.frame), 0.0f);
[_collectionView setContentOffset:offset];
}
}];
} completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
这是有效的,但由于焦点引擎也移动我的单元格(滚动它)我最终得到的动画不顺畅,在它的末尾有一个"踢".
是否可以使用iOS应用程序检测Apple TV 4 Siri Remote CoreBluetooth?我能够检测到Apple TV,但是我没有运气检测到Siri Remote.在Siri的远程使用蓝牙4.0,所以我假设它是检测到.理想情况下,我想检测Siri Remote,即使它已经与Apple TV配对了.
只需能够检测来自Siri Remote的任何信号/知道它在用户iPhone附近就是我所追求的.
#import "ViewController.h"
@import CoreBluetooth;
@interface ViewController () <CBPeripheralDelegate, CBCentralManagerDelegate>
@end
@implementation ViewController {
CBCentralManager *btManager;
}
-(void)viewDidLoad {
[super viewDidLoad];
btManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
}
#pragma mark - CBCentralManagerDelegate Methods
-(void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary<NSString *, id> *)advertisementData RSSI:(NSNumber *)RSSI {
NSLog(@"peripheral name: %@", peripheral.name);
NSLog(@"peripheral services: %@", peripheral.services);
NSLog(@"peripheral identifier: %@", peripheral.identifier);
NSLog(@"peripheral state: %ld", (long)peripheral.state);
NSLog(@"RSSI: %@ \n\n", RSSI);
}
-(void)centralManagerDidUpdateState:(CBCentralManager …Run Code Online (Sandbox Code Playgroud) 我已经按照本教程进行操作,一切正常。我遇到的唯一问题是我不知道如何检测按钮何时被按下?
提前致谢
UIPickerView 在 tvOS 中不可用。知道我的 Pickerview 的内容是动态的并且最多可以包含 10 个元素,我应该如何构建它的等效项。谢谢您的回答。
我正在尝试使用 SceneKit 为 tvOS 开发游戏,但遇到了问题。当我在向物理主体施加脉冲之前设置节点的 eulerAngle 时,节点将重置到其原始位置。
我期望看到节点在地板平面上移动,但在每次点击时,节点都会在施加脉冲之前移动到原点位置。
我是这个框架的新手,所以我想知道错误在哪里。我正在使用带有 tvOS 9.0 和 XCode 7.1.1 的新 AppleTV
要重现它,您可以创建一个新的 xcode 项目(Game for tvOS)并用以下代码替换 GameViewController.m:
#import "GameViewController.h"
SCNNode *ship;
SCNNode *node;
SCNNode *ground;
@implementation GameViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// create a new scene
SCNScene *scene = [[SCNScene alloc] init];
scene.physicsWorld.gravity = SCNVector3Make(0, -800, 0);
// create and add a camera to the scene
SCNNode *cameraNode = [SCNNode node];
cameraNode.camera = [SCNCamera camera];
cameraNode.camera.zFar = 10000;
[scene.rootNode addChildNode:cameraNode];
// place the camera …Run Code Online (Sandbox Code Playgroud) 我有一个简单的视图,它有两个文本视图和一个按钮。所有控件都垂直放置。我可以使用遥控器从一个控件导航到另一个控件。但是,我正在尝试使以下场景起作用:
虽然步骤 1-3 是开箱即用的,但以编程方式更改焦点 (4) 不起作用。这是一些代码:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
if(textField == self.textfieldB) {
self.activeView = self.textfieldB;
[self setNeedsFocusUpdate];
[self updateFocusIfNeeded];
return YES;
}
return NO;
}
Run Code Online (Sandbox Code Playgroud)
并且- (UIView *)preferredFocusedView我将返回存储在 self.activeView 中的任何内容(是的,它将返回按钮实例)。所有方法都按预期调用,但焦点不会改变。我在这里做错了什么?
提前致谢!
我正试图在tvOS上实现非常简单的用户界面,经过几次失败后,似乎不可能.
我有2个水平滚动的集合视图.
所有城市的选项集都相同,但某些城市可以禁用某些选项.每个城市至少有一个选项.
用户可以通过关注特定细胞来选择城市和选项.当前选择在屏幕上可见(请参阅集合视图下的标签)
我要做的是记住选定的城市/选项,所以当我更改thos集合视图之间的选项时 - 之前选择的项目变得集中(选中).这可以使用remembersLastFocusedIndexPathflag fo UICollectionView但集合视图忽略禁用的单元格.
例如,在附加项目中,都柏林禁用了选项3.因此,如果用户选择伦敦,则选择选项3,然后将焦点移回城市集合视图并将选择更改为都柏林,然后选项3将被禁用(是和返回).但是如果是真的 - 集合视图忽略所有这些并尝试集中禁用的项目.此时UI ob集合视图"破碎":isUserInteractionEnabledfalsecollectionView(_ collectionView:, canFocusItemAt indexPath:)falseremembersLastFocusedIndexPath
虽然从Apple的文档indexPathForPreferredFocusedView(in:)中看UICollectionView不出来,但是有一种方法,但它只针对首选触发一次.
有没有办法为聚焦细胞编写"自定义"逻辑?我需要为选项集合视图实现的是选择当前选择的选项(如果可用)或第一个可用选项(如果当前选择的选项在每次获得焦点时被禁用).子类化UICollectionView不应该是解决这个问题的方法,因为它不应该知道数据模型.
在这里,您可以下载测试项目
apple-tv ×10
tvos ×8
swift ×3
uikit ×3
objective-c ×2
airplay ×1
bluetooth ×1
focus-engine ×1
game-center ×1
ios ×1
iphone ×1
scenekit ×1
scnnode ×1
siri-remote ×1