Tag: uicollectionview

CollectionView的单元格不适合屏幕

我在TableView单元格中有CollectionView : CollectionView单元格的约束 当我在iPhone 5s上运行app fe时,我发现(单元格不适合屏幕显示): 但是,滚动后,我看到: 我知道重用,但如何显示细胞从开始必须(适合屏幕)?

UICollectionView在删除节时崩溃

当使用这个代码 – (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { [self removeCompany:companySelectedInActionSheet]; NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex: indexPathSelectedInActionSheet.section]; NSLog(@"IndexSet to delete from collection view: %@",indexSet); [self.collectionView deleteSections:indexSet]; } } 我的应用有时会崩溃(10%的时间)与此错误: *** Assertion failure in -[UICollectionView _endItemAnimations], /SourceCache/UIKit_Sim/UIKit-2903.2/UICollectionView.m:3700 有什么想法可能是错的? 在删除之前提交的操作表是一个潜在的问题吗? 在删除集合视图部分之前,是否需要手动解除它?

数组objectAtIndex:超出界限的错误

所以最近,我很难找出如何创build一个uicollectionview的search栏(请看这里 )。 幸运的是,有人能够为我回答。 但是,由于滚动我的应用程序是非常缓慢和越野车,我决定实施一个asynchronous的请求,使图像加载在后台,并因此加载,更快。 问题是我的包含search查询的数组无法“重新加载”我的uicollectionview,因为asynchronous请求正在干扰它。 或者至less,这就是我认为的问题,如果问题在别的地方,请告诉我。 这是我不断收到的错误消息: 2014-07-21 16:28:22.199 A Great App for TF2[545:70b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]' *** First throw call stack: ( 0 CoreFoundation 0x01c2e5e4 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x019b18b6 objc_exception_throw + 44 2 CoreFoundation 0x01bcf4e6 -[__NSArrayM […]

closures具有导航控制器的视图控制器并将值传递回主视图控制器

我有一个mainViewcontroller在一个button调用get mainViewcontroller我打电话dataviewcontrollerselect集合视图单元格中的任何项目。一旦用户select任何单元格。该特定的dataviewcontroller将解雇,而解雇它将有用户select的项目名称和它将显示在mainViewcontroller 。现在的视图控制器不是解雇。 这里代码: 在我的mainViewcontroller : var SelectedName: String? = "" override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) currentTF.text = SelectedName } 现在dataviewcontroller : func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { if collectionView.cellForItem(at: indexPath) != nil { selectedNamesss = allitems[indexPath.row] as String } calldismiss() print(selectedNamesss) } func calldismiss() { if let presenter = presentingViewController […]

从UICollectionView的popup视图导致放松

我有一个显示在UICollectionView的数据matrix(玩家)。 当用户触摸一个单元格时,我需要在弹窗视图中显示一个玩家的细节。 我早些时候问过这个问题,然后才开始工作。 但从那时起,一个奇怪的问题就出现了。 当我触摸一个单元格,popup窗口出现,但主视图展开两个屏幕(!?)和应用程序崩溃与此错误: 终止应用程序由于未捕获exception'NSGenericException',原因:' – [UIPopoverController dealloc] popover仍然可见。 playerDataView内置在故事板中。 我已经在其头文件中声明了playerDataView控制器和popover视图控制器作为集合视图的属性: @property (strong, nonatomic) UIPopoverController *playerDataPopover; @property (strong, nonatomic) SWSPlayerDataViewController *playerDataView; 以下是实例化popover的代码: – (IBAction)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row == 0 || indexPath.section == 0) { // Ignores user selecting row or column headers that I've placed in the collection view data return; […]

当使用自定义布局时,sizeForItemAt方法不会调用

我为我的集合视图使用自定义布局,但如果我使用自定义布局sizeForItemAt方法不调用。 我的自定义布局: public class HorizontalCollectionViewLayout : UICollectionViewLayout { var itemSize = CGSize(width: 0, height: 0) { didSet { invalidateLayout() } } private var cellCount = 0 private var boundsSize = CGSize(width: 0, height: 0) public override func prepare() { cellCount = self.collectionView!.numberOfItems(inSection: 0) boundsSize = self.collectionView!.bounds.size } public override var collectionViewContentSize: CGSize { let verticalItemsCount […]

集合视图单元格不显示在集合视图中?

我使用纯粹的故事板界面构build器创build了一个集合视图。 这是故事板的样子: 我的collections视图的属性也是默认的。 我还没有写任何东西到我的ViewController.swift 。 出于某种原因,当我在我的手机/模拟器上运行,没有任何button显示。

在UICollectionView中删除一个单元格后,单元格布局刷新

我创build了一个dynamic调整单元格高度的UICollectionView。 我正在调整这个单元格的大小: func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let approximatedwidthoftextview = view.frame.width – 70 let size = CGSize(width: approximatedwidthoftextview, height: 1000) let attributes = [NSAttributedStringKey.font: UIFont(name: "Avenir Next", size: 18)] let estimatedFrame = NSString(string: allnotes[indexPath.row].note).boundingRect(with: size, options: .usesLineFragmentOrigin, attributes: attributes, context: nil) return CGSize(width: view.frame.width, height: estimatedFrame.height + […]

如何在swift 3中实现表视图单元格中的集合视图的分页?

在这里我有布局,其中我的表视图单元格中的一个由集合视图组成,在这我需要实现分页,我无法使用func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath)函数现在如何实现分页的表视图任何人都可以帮助我如何实现这个地方的条件,当它到达我的集合视图的最后一个元素,在这里我知道如何实现分页,但如何调用需要重新加载的函数? 这是我用来检测最后一个单元格的函数,并使用下面的函数来重新加载数据 func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { let obj = items let lastElement = (obj.count) – 1 print(lastElement) if !loadingData && indexPath.row == lastElement { loadingData = true guard let obj = self.listClassModel else { return } if ((obj.searchCriteria.pageSize as? […]

问题与传递适当的图像到tableviewcell

这是我的结构… struct ProductImage { let id : String let url : URL let isDefault : Bool } struct Product { let name : String let id : String var images = [ProductImage]() init(name : String, id: String) { self.name = name self.id = id } mutating func add(image: ProductImage) { images.append(image) } } 现在我有一个图像加载在collectionview上,点击一个button,我想把这个图像传递给tableviewcell 。 […]