Tag: 自我评价

UICollectionView:有没有办法只重新加载补充意见?

我有一个与每个部分的补充视图的uicollectionview。 在每个补充视图中我都有一些button。 在dataSource方法collectionView:viewForSupplementaryElementOfKind:atIndexPath:我使用indexPath.section设置button标签。 当按下button时,我做了一些委托方法,并发送部分(button.tag)作为参数。 一切工作正常,但问题来了: 当我插入或删除一个部分,它必须更新button标签,但我不想重新加载每个部分的所有项目。 我试过了: 使用dataSource方法collectionView:viewForSupplementaryElementOfKind:atIndexPath:来获取补充视图,并为每个辅助 视图调用layoutIfNeeded方法,这样补充 视图就是重新加载的,但是这种方法会乘以我的补充 视图 。 一个快速的在collectionView.subviews并得到只是补充 视图和调用layoutIfNeeded方法,但它不重新加载,只是布局正在重新加载。 reloadSections:方法,但会重新加载该部分的所有项目 哦,我使用NSFetchedResultsController (委托)插入和删除部分。 谁能帮我这个? 有没有办法只重新加载补充视图 ? 这种情况下还有其他方法吗? 谢谢!

不调用cellForItemAtIndexPath,但numberOfItemsInSection

这可能是一个重复的post,但我还没有find任何解决scheme: 我设置我的UICollectionView为: UINib *nib = [UINib nibWithNibName:@"CollectionViewCell" bundle:[NSBundle mainBundle]]; [_collectionView registerNib: nib forCellWithReuseIdentifier:@"bCell"]; (我试图设置代表,没有委托,等等)。 但是,只有这个 – (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section被调用while – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath不。 我检查了numberOfItemsInSection我返回,它总是> 0(正好17)。 我已经检查过要调用[_collectionView reloadData]; 也没有任何反应。 我尝试过不同的事情,但是我无法做到这一点。 此外,我的UICollectionView应该在这里,但它不是: 有人有线索吗? 谢谢。

如何创buildUICollectionView而不使用故事板?

我在网上find了一些很好的UIcollectionview教程 Beginning UICollectionView In iOS 6: Part 1/2 http://ashfurrow.com/blog/uicollectionview-example 没有故事板可以使用collectionview吗? 使用collectionview的故事板有什么优点和缺点?

在UICollectionView中以编程方式select项目

我有一个UICollectionViewController : – (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return [self.pageTastes count]; } – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { CellTasteCollectionView *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; Taste *taste = [self.pageTastes objectAtIndex:indexPath.item]; [[cell imageView] setImage:taste.image]; [cell setObjectId:taste.objectId]; return cell; } 有用。 我有这个viewDidLoad ,允许用户select多个项目: [self.collectionView setAllowsMultipleSelection:YES]; 我想要的是,第一次加载CollectionView,一些项目被选中编程,基于它们在CellTasteCollectionView objectId 。 以下是我如何做到这一点: – (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ Taste *taste = [self.pageTastes […]

selectUICollectionView iOS中的所有项目,甚至是不可见的单元格

我正在创build一个应用程序,在工具栏上有一个button,用于select集合视图中的所有项目。 但是我面对的问题是,当我点击button时,只select屏幕上可见的项目。 这是由于CELL REUSEfunction。 有什么办法可以select所有的单元格,即使是那些目前不可见的单元格? 谢谢J

调用reloadData时,UICollectionView不会立即更新,而是在30-60秒后随机更新

正如标题所暗示的,我的UICollectionView不会在调用reloadData之后立即更新和显示单元格。 相反,它似乎最终在30-60秒后更新我的collections视图。 我的设置如下: UICollectionView添加到视图控制器在故事板与delegate和dataSource设置为视图控制器和标准sockets设置numberOfSectionsInRow & cellForItemAtIndexPath都实现了并引用原型单元格和cellForItemAtIndexPath里面 这里是转到Twitter的代码,得到一个时间表,把它分配给一个variables,重新加载一个表视图与推文,然后通过推文find照片,并重新加载收集视图与这些项目。 即使我注释掉代码来显示图像,它仍然不会改变任何东西。 SLRequest *timelineRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:timelineURL parameters:timelineParams]; [timelineRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { if(responseData) { JSONDecoder *decoder = [[JSONDecoder alloc] init]; NSArray *timeline = [decoder objectWithData:responseData]; [self setTwitterTableData:timeline]; for(NSDictionary *tweet in [self twitterTableData]) { if(![tweet valueForKeyPath:@"entities.media"]) { continue; } for(NSDictionary *photo in [[tweet objectForKey:@"entities"] […]

UICollectionView的cellForItemAtIndexPath没有被调用

只有我第二次使用UICollectionView的,也许我咬了更多比我可以咀嚼,但不过: 我正在实现一个UICollectionView(myCollectionView),它使用自定义UICollectionViewCell我已经subclassed。 子类(FullReceiptCell)包含UITableView的和是视图控制器的大小。 我试图让FullReceiptCells之间的水平滚动。 包含myCollectionView的子类UICollectionViewController被推送到导航控制器堆栈。 目前,启用myCollectionView和水平滚动。 但是,没有可见的单元格。 我已经证实了 – (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section 已经运行并返回一个大于0的整数。我也确认myCollectionView的委托和数据源在IB中正确设置为子类UICollectionViewController。 要加载单元格的方法: – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 没有被调用。 这里是我在该控制器中推送UICollectionViewController和我的viewDidLoad方法的地方(注意:initWithBill是正常初始化程序的覆盖): 在以前的ViewControllers .m文件中: FullReceiptViewController *test = [[FullReceiptViewController alloc] initWithBill:currentBill]; test.title = @"Review"; [self.navigationController pushViewController:test animated:YES]; 在FullReceiptViewController.m中: – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. [self.myCollectionView […]

在UICollectionView中显示不同数量的单元格

我想有一个UICollectionView ,在第一行有一个单元格的所有行的宽度,第二行有3个单元格。 我已经研究过文档,但是我无法做到。 像这样的东西: 提前致谢

在UICollectionView中的单元格顺序

我需要创build一个UICollectionView与不同大小的单元格( UICollectionView )。 我已经编码添加单元格,取决于他们使用的是什么尺寸的collectionView:layout:sizeForItemAtIndexPath: 这是预期的结果(单元格1和单元格3必须位于单元格2的左侧): 但是目前的结果是: 我的(丑)目前的代码是(self.cellSize =屏幕宽度/ 3): – (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { CGFloat size = self.cellSize; if (indexPath.item == 0) { return CGSizeMake(self.cellSize * 3.f, self.cellSize * 2.5f); } if (indexPath.item == 1) { return CGSizeMake(self.cellSize, self.cellSize); } if (indexPath.item == 2) { return CGSizeMake(self.cellSize * 2.f, self.cellSize * 2.f); […]

如果select了单元格,则不调用UICollectionView – didDeselectItemAtIndexPath

我做的第一件事就是设置选中的单元格。 – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; cell.selected = YES; return cell; } 细胞成功select。 如果用户触摸选定的单元格,则应取消select单元格并调用代表。 但是这绝不会发生。 – (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"%s", __PRETTY_FUNCTION__); } – (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"%s", __PRETTY_FUNCTION__); } 我知道,如果我以编程方式设置select,则不会调用委托。 代表和数据源被设置。 但是,这个代表被调用: – (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"%s", __PRETTY_FUNCTION__); return YES; } […]