Tag: uicollectionview

在第一次加载时预先select/高亮显示UICollectionViewCell

我试图预先selectUICollectionView中的第一个对象/ UICollectionViewCell? 我努力了: self.dateCollectionView.allowsMultipleSelection=NO; [self.dateCollectionView selectItemAtIndexPath:0 animated:YES scrollPosition:UICollectionViewScrollPositionLeft]; [self collectionView:self.dateCollectionView didSelectItemAtIndexPath:0]; [self.dateCollectionView reloadData]; 在viewDidLoad 。 这里是我的UICollectionView方法; -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ return self.titles.count; } -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ UICollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; cell.backgroundColor= [UIColor clearColor]; UILabel * dateLabel = (UILabel *)[cell viewWithTag:1]; UILabel * subText = (UILabel *)[cell viewWithTag:2]; subText.text=self.titles[indexPath.row]; subText.adjustsFontSizeToFitWidth=YES; if (cell.selected) […]

使用UICollectionViewCell上的button来显示数组中的数据

我有一个NSStrings的数组,一个UILabel和一个UICollectionView 。 我的问题: 我想要数组的数量来确定有多less个UICollectionViewCell 。 每个UICollectionViewCell包含一个button。 点击后,我想要这个button,使数组中对应于UICollectionViewCell编号的数据显示在标签中。 例如,如果用户点击第十三个UICollectionViewCell的button,那么数组中的第十三个NSString将成为UILabel的文本。 我做了什么: 我为UICollectionViewCell创build了自己的子类,用于所有UICollectionViewCell的nib文件, UICollectionViewCell该button作为IBAction连接到.h文件。 我还导入了MainViewController.h ,它是包含存储NSString的数组属性的MainViewController.h 。 当我编辑UICollectionViewCell的操作中的代码时,我无法访问数组属性。 button确实有效 – 我把NSLog放在了IBAction的方法中,它可以工作。 我已经search了其他几十个答案,但没有回答我的具体问题。 如果需要,我可以用我的代码样本更新这个。

UICollectionView indexPathsForVisibleItems不更新新的可见单元格

我有一个ViewView里面有一个CollectionView。 加载视图时,可见单元格(9个单元格)正确显示。 当我向下滚动时,我想通过调用indexPathsForVisibleItems for partnerCollectionView在loadImagesForOnscreenRows中加载collectionView中的可见项。 但是,当loadImagesForOnscreenRows indexPathsForVisibleItems总是前9个单元格,即使单元格10到18应该在屏幕上可见。 我使用的代码是: #import "PartnerListViewController.h" #import "AppDelegate.h" #import "Partner.h" #import "ImageLoader.h" #import "PartnerDetailViewController.h" @interface PartnerListViewController () @end @implementation PartnerListViewController @synthesize lblTitle; @synthesize partnerCollectionView; @synthesize imageDownloadsInProgress; @synthesize fetchedResultsController; @synthesize managedObjectContext; – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. AppDelegate * appDelegate = (AppDelegate *) [[UIApplication […]

插入到包含页脚的UICollectionView部分的问题

我有一个典型的UICollectionView,它以垂直方式使用UICollectionViewFlowLayout。 我正在使用分页API来填充集合视图。 为了触发下一个页面的下载,我在使用委托时要求页脚布局: – (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{ RDLoadMoreReusableView *view = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"RDLoadMoreReusableView" forIndexPath:indexPath]; view.delegate = self; [view start]; [self loadNextPageOfAssets]; return view; } 这里是我的loadNextPageOfAssets背后的代码: -(void)loadNextPageOfAssets{ __weak RDRadiusGridViewController *weakSelf = self; // Increment page and request assets. They are added to cluster.assets before the completion block is called. self.cluster.pagination.page++; [self.cluster requestAssetsWithCompletionBlock:^(NSArray […]

Swift,以编程方式更改UICollectionViewCell和UILabel(在单元格内)的宽度

我已经设置了一个单元格(UICollectionViewCell)的宽度等于UICollectionView的宽度,我正在尝试与该单元格内包含的UILabel完全相同的事情。 我认为下面的代码正是我想要达到的目标。 所以我在这里读了一些问题,还有几个教程,但我仍然不知道我怎么能做到这一点。 在几个问题中,它是关于使用collectionViewLayout说法,但我真的在如何在我的代码中使用它挣扎。 有任何想法吗? 谢谢! func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { var cell = collectionView.dequeueReusableCellWithReuseIdentifier("myCell", forIndexPath: indexPath) as LocationViewCell cell.locationLabel.text = "Hello there!" // Set cell & label width to 100% let collectionViewWidth = self.collectionView.bounds.size.width cell.frame.size.width = collectionViewWidth // Works cell.locationLabel.frame.size.width = collectionViewWidth // Does NOT 更新1 所以我添加了以下内容: func collectionView(collectionView: UICollectionView, […]

在UICollectionViewCell中的UICollectionView

我有兴趣有一个collectionview作为一个集合视图单元格的一部分,但由于某种原因无法弄清楚如何做到这一点。 我将在哪里实施细胞collectionview的必要的方法?

根据UICollectionView中的图像dynamic更改单元大小

我在水平集合视图中显示从服务器接收的dynamic图像。 当我设置collectionview时,我设置了这个: -(void)setupCollectionView{ [self setupPageControlView]; self.screensCollectionView.delegate=self; self.screensCollectionView.dataSource=self; [self.screensCollectionView registerNib:[UINib nibWithNibName:@"FGAppScreensCollectionViewItemCell" bundle:nil] forCellWithReuseIdentifier:@"screenCell"]; UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; [flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal]; [flowLayout setMinimumInteritemSpacing:0.0f]; [flowLayout setMinimumLineSpacing:0.0f]; [flowLayout setItemSize:CGSizeMake(165, 255)]; //[self.screensCollectionView setPagingEnabled:YES]; [self.screensCollectionView setCollectionViewLayout:flowLayout]; } 对于cellForRowAtIndexPath我下载像这样的图像: -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ static NSString *cellIdentifier = @"screenCell"; FGAppScreensCollectionViewItemCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:[self.imageURLArray […]

如何在UIScrollView中实现不可滚动的UICollectionView?

简而言之,我所需的屏幕布局基本上是一个用户configuration文件(iOS 7 + Xcode 5)。 我用UIScrollView作为顶层视图。 原因是我想要滚动它的所有子视图 (用户信息视图 – 一个configuration文件图像和一些button,你在屏幕上看到的,和照片集合视图 – 一个黑色的背景)。 黑色背景的地区将显示用户照片。 我想知道是否可以在这里使用UICollectionView,或者有更好的方法来实现它。 在这种情况下,UICollectionView不应该能够自己滚动,它只显示所有单元格,而滚动工作由最外层的UIScrollView处理。 我读了以下post: UIScrollView里面的UICollectionView UIScrollView中的UICollectionView – >滚动顺序 滚动视图中的iOS 7集合视图 有人说,在UIScrollView中实现UICollectionView是不可能的(或者至less是奇怪的),因为UIScrollView是UICollectionView的超类,这会导致意外的行为。 有人说应该以另一种方式来实施(但我没有看到明确的build议)。

UIImage内存不释放VM:ImageIO_JPEG_DATA?

我在屏幕上有多个水平滚动的collections视图。 他们都充满了图像。 所有这些图像都通过Parse api在后台加载。 我正在运行Instrument的分配和匿名VM:ImageIO_JPEG_DATA类别占用了正在使用的大部分内存。 应用程序中的所有内存大约等于40,然后这个类别超过55,这就使总数大约为100.这个类别从来没有下降过,只是保持一致。 我能做些什么来从我的collections视图中的图像中释放这些内存? 以下是我的collections视图的代码: .m为我的collections视图控制器 – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionViewCell" forIndexPath:indexPath]; if (cell) { [cell.loadingImageIndicator setHidden:NO]; [cell.loadingImageIndicator startAnimating]; id photo = [self.collectionViewPhotos objectAtIndex:indexPath.item]; if ([photo isKindOfClass:[PFObject class]]) { PFObject *photoObject = (PFObject *)photo; PFFile *imageFile = [photoObject objectForKey:kPhotoPictureKey]; [cell.cellImage setFile:imageFile]; [cell.cellImage loadInBackground:^(UIImage *image, NSError […]

uicollectionview在reloaddata之后立即select一个项目?

调用之后-[UICollectionView reloadData]需要一些时间来显示单元格,所以在调用reloadData之后立即select一个项目不起作用。 有没有办法在reloadData之后立即select一个项目?