Вот мой самый простой код. Он показывает пять ячеек в UICollectionView (каждая ячейка с простой кнопкой). Все кнопки указывают на единственный метод IBAction. Все это настраивается в Main.storyboard.
Я не могу заставить tvOS сфокусироваться на кнопках. Есть идеи, почему?
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return 5;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MyCell" forIndexPath:indexPath];
return cell;
}
- (IBAction)buttonAction
{
// do stuff
}
@end