Spo*_*ude 2 objective-c ios xcode4.5 uicollectionview uicollectionviewcell
我有一个iPad应用程序,使用Storyboard,Tab Bar和XCode 4.5.我的一个场景在左上象限中有一个UITableView,在右上象限中有标签和UITextBox.
当我点击第二个标签时,我将进入上述场景.这是代码:
- (void)viewDidLoad {
[super viewDidLoad];
[self.collectionView registerClass:[Cell class] forCellWithReuseIdentifier:@"MY_CELL"];
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 4;
}
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section {
return 4;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath; {
Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"MY_CELL" forIndexPath:indexPath];
cell.label.text = [NSString stringWithFormat:@"%d",indexPath.item];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
这是接口定义:
@interface ClientViewController : UIViewController <UICollectionViewDelegate, UICollectionViewDataSource> {
}
Run Code Online (Sandbox Code Playgroud)
这是错误:
*由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [UIView collectionView:numberOfItemsInSection:]:无法识别的选择器发送到实例0x7d925b0'
如您所见,我对numberOfSectionsInCollectionView使用了相同的代码.我研究过SO和Google,但没有发现任何适用的内容.
我究竟做错了什么?
| 归档时间: |
|
| 查看次数: |
2996 次 |
| 最近记录: |