ios - UITableView 和 tvOS 的新方法

标签 ios objective-c uitableview focus tvos

我正在创建一个测试 tvOS 应用程序。我有一个图像(在 tableview 之外),当未选择“聚焦”时,我希望图像发生变化......我知道苹果已经添加了几种聚焦方法。有人能告诉我当它处于“焦点”时我会使用哪些方法来更改此图像?我将如何使用它? 我会使用这种方法吗:

   - (BOOL)tableView:(UITableView *)tableView canFocusRowAtIndexPath:(NSIndexPath *)indexPath

或者我会使用:

  - (void)tableView:(UITableView *)tableView didUpdateFocusInContext:(UITableViewFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator

请告诉我!谢谢!

最佳答案

如果你想在 UITableViewCell 项目获得焦点时改变图像,那么你应该使用第二种方法。

 - (void)tableView:(UITableView *)tableView didUpdateFocusInContext:(UITableViewFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator
{
   //You can get focused indexPath like below
   NSIndexPath *nextIndexPath = [context nextFocusedIndexPath];
   // Now get image from data source, I will assume you have an images array
   UIImage *image = [_imagesArray objectAtIndex:nextIndexPath.row];
   // Set image to image view, assuming you have a property imageView
   _imageView.image = image;
}

关于ios - UITableView 和 tvOS 的新方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32915704/

相关文章:

ios - OS 9.2 Xcode 7.2 中的 Google 登录问题

ios - Split View Controller 显示模式更改后更新应用程序用户界面?

ios - PFQuery includeKey 似乎不起作用 : Key data unavailible

objective-c - 以编程方式跟踪 Mac 上事件应用程序的最佳方法是什么

ios - UITableViewCell 动态高度服务器端

iphone - 我怎样才能在 iPhone 应用程序中捕获所有异常

android - 在 iOS 和 Android 之间共享代码的最佳方式

ios - 关闭作为 UITableViewCell 子类的属性以更新值 : Is it a bad idea?

swift - 用数据填充 TableView

ios - UITableViewController 中的静态单元格未在模拟器中显示内容