Nivo滑块不居中(Nivo Slider is not centered)
查看http://waterski.allthingswebdesign.com/index.php/site/index ,您可以看到我的Nivo滑块不在背景中心。 我无法弄清楚为什么会这样。 (忽略第2张和第3张照片,因为我知道它们的尺寸不正确,但第1张照片是正确的)。
Check out http://waterski.allthingswebdesign.com/index.php/site/index and you can see that my Nivo Slider is not centered on the background. I can't figure out why this is. (ignore the 2nd and 3rd pictures as I know they are not the correct size, but the 1st one is).
原文:https://stackoverflow.com/questions/6681658
最满意答案
只是猜测:在插入第一张图像时,收藏视图可能尚未加载其数据。 但是,在异常消息中,集合视图声明“知道”插入之前的项目数量(1)。 因此,它可能在
insertItemsAtIndexPaths:
延迟加载其数据insertItemsAtIndexPaths:
并将结果作为“之前”状态。 此外,插入后无需重新加载数据。长话短说,移动了
[cv reloadData];
得到
if ([imageViews count] == 0) { [self.noImagesLabel removeFromSuperview]; [self.imageDisplayCell.contentView addSubview:cv]; [cv reloadData]; }
Just a guess: at the time you are inserting the first image, the collection view may not yet have loaded its data. However, in the exception message, the collection view claims to "know" the number of items before the insertion (1). Therefore, it could have lazily loaded its data in
insertItemsAtIndexPaths:
and taken the result as "before" state. Also, you don't need to reload data after an insertion.Long story short, move the
[cv reloadData];
up to get
if ([imageViews count] == 0) { [self.noImagesLabel removeFromSuperview]; [self.imageDisplayCell.contentView addSubview:cv]; [cv reloadData]; }
相关问答
更多-
插入到包含页脚的UICollectionView部分的问题(Issues inserting into UICollectionView section which contains a footer)[2022-09-18]
VaporwareWolf提供的答案有点破解。 通过返回小尺寸而不是零尺寸,补充视图将始终存在,但尺寸太小而无法看到。 所以这就是它修复NSInternalInconsistencyException的原因 但是,有一个真正的解决方案 。 将数据添加到数据源并在调用insertItemsAtIndexPaths 之前 ,只需使collectionview上的布局无效,以使其知道更改。 Objective-C的 [self.collectionView.collectionViewLayout invalid ... -
当将第一个单元格插入到集合视图中时,遇到了同样的问题。 我通过更改我的代码来修复问题,以便调用UICollectionView - (void)reloadData 插入第一个单元格的方法,但是 - (void)insertItemsAtIndexPaths:(NSArray *)indexPaths 插入所有其他单元格时。 有趣的是,我也有一个问题 - (void)deleteItemsAtIndexPaths:(NSArray *)indexPaths 删除最后一个单元格时。 我做了与之前相同的事 ...
-
UICollectionView insertItemsAtIndexPaths:抛出异常(UICollectionView insertItemsAtIndexPaths: throws exception)[2022-03-31]
只是猜测:在插入第一张图像时,收藏视图可能尚未加载其数据。 但是,在异常消息中,集合视图声明“知道”插入之前的项目数量(1)。 因此,它可能在insertItemsAtIndexPaths:延迟加载其数据insertItemsAtIndexPaths:并将结果作为“之前”状态。 此外,插入后无需重新加载数据。 长话短说,移动了 [cv reloadData]; 得到 if ([imageViews count] == 0) { [self.noImagesLabel removeFromSupe ... -
您的performBlock保存时间过长。 您可以 只需保存在主线程上。 应该花费一瞬间来保存500本书,并且由于UI中没有任何重要的事情发生(用户在等待),因此无需在一个块中执行此操作。 请改用performBlockAndWait 。 只有在保存完成后才会更新表视图。 用户的结果与保存主线程非常相似。 使用NSFetchedResultsControllerDelegate而不进行块操作。 遵循Xcode提供的获取结果控制器模板。 这可能比仅保存主线程更慢,因为UI将获得多个更新。 Your perfo ...
-
问题是在日志中说标题不能是nil.So在那里给出一些有效的输入,你可以避免崩溃。 就像标题部分不需要输入一样,给它一个clearclolor视图 要实现标头部分,必须实现以下数据源方法 - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)index ...
-
在UICollectionView中在当前索引之前添加对象(Adding an object before the current index in UICollectionView)[2022-05-31]
该错误表示更改数据源时出现数据源问题。 可变字典中的键数不正确。 据推测,您使用NSIndexPath作为键和所需的数据作为值。 我认为使用数组更容易( indexPath.row会以正确的顺序指向正确的对象)。 检查更新方法,在其中更改数据源中的数据。 您应该确保您的词典包含预期的项目数。 在您的错误消息中,插入前后的1项似乎表明您的字典可能nil ,因此返回零计数。 确保您具有正确实例化的实例变量。 The error indicates a data source issue when changin ... -
在viewDidLoad()下的NextViewController.swift添加了以下两行: var nibName = UINib(nibName: "GalleryCell", bundle:nil) collectionView.registerNib(nibName, forCellWithReuseIdentifier: "CELL") 问题是我没有注册笔尖。 现在我正在这样做,它工作正常。 I added the following two lines in NextViewContro ...
-
我相信问题与在不更新数据源的情况下从UITableView中删除项目时出现的问题相同,从而导致异常。 请尝试以下方法: [self.datasource removeObjectAtIndex:iPath.row]; //... delete the row from the collectionView. I believe that the problem is the same as the one that arises when you delete an item from a UITable ...
-
UICollectionView - 在一个视图上更新动画太多(UICollectionView - too many update animations on one view)[2022-04-21]
凉! 最新版本的RxUI与UITableView, ReactiveTableViewSource类似。 我对NSInternalInconsistencyException也有一些棘手的问题: 如果您的任何更新都是重置,您需要忘记执行其他所有操作 如果应用程序在同一次运行中添加并删除了相同的项目,则需要检测并对其进行去抖(即甚至不告诉UIKit)。 当您意识到添加/删除可以更改索引范围而不仅仅是单个索引时,这会变得更加棘手。 Cool! The latest version of RxUI has a s ... -
它是否像这样,像一个魅力: [localCollectionView performBatchUpdates:^{ [localCollectionView insertItemsAtIndexPaths:indexPaths]; [localLabelCollectionView insertItemsAtIndexPaths:indexPaths]; } completion:^(BOOL finished) { hatching = NO; }]; 好像performBa ...