所以我试图制作带有集合视图的自定义键盘。
在我的KeyboardViewController.m中我有
UIView *keyboardView = [[[NSBundle mainBundle] loadNibNamed:@"KeyboardView" owner:nil options:nil] objectAtIndex:0];
[keyboardView setFrame:self.view.bounds];
[self.view addSubview:keyboardView];
使用自定义界面加载XIB。
在KeyboardView中,我有UICollectionView
个自定义单元格和自定义方法来初始化它
- (void)loadKeyboard {
NSLog(@"test");
self.tabsArray = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"tab1.png"], [UIImage imageNamed:@"tab2.png"], [UIImage imageNamed:@"tab3.png"], [UIImage imageNamed:@"tab4.png"], [UIImage imageNamed:@"tab5.png"], [UIImage imageNamed:@"tab6.png"], nil];
self.tabsCollectionView.dataSource = self;
self.tabsCollectionView.delegate = self;
self.tabsCollectionView.backgroundColor = [UIColor whiteColor];
[self.tabsCollectionView registerNib:[UINib nibWithNibName:@"TabCollectionViewCell" bundle:[NSBundle mainBundle]]
forCellWithReuseIdentifier:@"myCustomCell"];
[self.tabsCollectionView reloadData];
}
我测试了几次,发现UICollectionView
委托方法(如- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
)未被调用。我错过了什么?