当我调用uicollectionview 的reloadData方法时出现异常,也没有提示,不知道怎么会是?
请高手帮忙?这是我写的代码:UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
[flowLayout setItemSize:CGSizeMake(85, 130)];
//[flowLayout setHeaderReferenceSize:CGSizeMake(320, 29)];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
self.collectionView=[[UICollectionView alloc]initWithFrame:CGRectMake(0, 213, 320, 800) collectionViewLayout:flowLayout];
self.collectionView.showsVerticalScrollIndicator=NO;
self.collectionView.scrollEnabled=NO;
self.collectionView.dataSource=self;
self.collectionView.delegate=self;
///////////////////
UIColor *color=[UIColor colorWithPatternImage:[UIImage imageNamed:@"collection_bg.png"]];
[self.collectionView setBackgroundColor:color];
///////////////////
[self.scrollView addSubview:self.collectionView];
以下是collectionView的委托方法-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 15;
}-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
myCell=(MyCollectionViewCell*)[collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionCell" forIndexPath:indexPath];
[myCell.imageViev setImage:[UIImage imageNamed:@"yurnal.png"]];
[myCell.titleLabel setFont:myFont];
[myCell.infoLabel setFont:myFont];
[myCell.titleLabel setText:[NSString stringWithFormat:@"test%d",indexPath.row]];
return myCell;
}-(UICollectionReusableView*)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
CollectionViewHeader* myHeader=[collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"myHeader" forIndexPath:indexPath];
[myHeader setTitle:@"最新"];
return myHeader;
}- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsMake(15, 10, 5, 10);
}请高手帮忙!!!,谢谢
请高手帮忙?这是我写的代码:UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
[flowLayout setItemSize:CGSizeMake(85, 130)];
//[flowLayout setHeaderReferenceSize:CGSizeMake(320, 29)];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
self.collectionView=[[UICollectionView alloc]initWithFrame:CGRectMake(0, 213, 320, 800) collectionViewLayout:flowLayout];
self.collectionView.showsVerticalScrollIndicator=NO;
self.collectionView.scrollEnabled=NO;
self.collectionView.dataSource=self;
self.collectionView.delegate=self;
///////////////////
UIColor *color=[UIColor colorWithPatternImage:[UIImage imageNamed:@"collection_bg.png"]];
[self.collectionView setBackgroundColor:color];
///////////////////
[self.scrollView addSubview:self.collectionView];
以下是collectionView的委托方法-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 15;
}-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
myCell=(MyCollectionViewCell*)[collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionCell" forIndexPath:indexPath];
[myCell.imageViev setImage:[UIImage imageNamed:@"yurnal.png"]];
[myCell.titleLabel setFont:myFont];
[myCell.infoLabel setFont:myFont];
[myCell.titleLabel setText:[NSString stringWithFormat:@"test%d",indexPath.row]];
return myCell;
}-(UICollectionReusableView*)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
CollectionViewHeader* myHeader=[collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"myHeader" forIndexPath:indexPath];
[myHeader setTitle:@"最新"];
return myHeader;
}- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsMake(15, 10, 5, 10);
}请高手帮忙!!!,谢谢
解决方案 »
- 急!!!怎样在iOS中对PDF文件合成
- iOS开发,刚毕业进公司接了个项目,写一个工具类。第一次弄这个真的很茫然,求高手帮忙小弟不胜感激!!!
- 求cocoa编程中文版,iphone编程中文版地址
- 求教button如何实现按下之后更改按钮背景图片
- Object_C和C++什么关系
- 为什么在这里会出现“EXC_BAD_ACCESS”. 上面并没有release ArrLat 啊。。求解
- 按下变灰这个功能如何做?
- 一个项目引用另外一个项目的AppDelegate
- 本人有2年的java开发经验,想自学ios,以后想转移动端开发
- Swift语言快速入门教程
- tintcolor是什么意思
- 关于json解析问题
self.collectionView=[[UICollectionView alloc]initWithFrame:CGRectMake(0, 213, 320, 800) collectionViewLayout:flowLayout];
初始化的时调用[collectionView reloadData];就出异常
但不知道怎么解决