这是我的基本代码。它在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
答案 0 :(得分:3)
或者你可以
- (BOOL)collectionView:(UICollectionView *)collectionView canFocusItemAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}