我正在尝试将UILabel固定到它的父细胞上.我添加了四个约束(顶部,前导,尾随,底部),它们在iOS 8.0上运行良好,但在iOS 7.X上运行不正常.请看下面的图片:

我究竟做错了什么?请指教!
它似乎只是在Xcode 6 GM之后才被打破.我的方法在Xcode 6 beta 7中运行良好.
此外,如果我减少内部视图的宽度,它会抛出以下警告:
2014-09-10 19:58:28.109 Test[57827:60b] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to …Run Code Online (Sandbox Code Playgroud) 如果我理解正确,a的内容UICollectionViewCell应该进入其contentView属性和背景backgroundView.
然而,当我拖动UICollectionViewCell到Interface Builder时,没有提到contentView或backgroundView.如果我添加子视图,那些将整个单元格作为其父级,而不是contentView或backgroundView.
那么UICollectionViewCell用IB 定义一个正确的方法是什么?
iphone interface-builder ios uicollectionview uicollectionviewcell
我在我的故事板(iPad)中定义了一个包含a的视图UICollectionView,在视图的底部还有一个UIToolbar.在UICollectionView我添加了一个UICollectionViewCell(由iPadCellCollectionViewCell类实现),其中包含另一个视图,它是一个Core-Plot Graph(一个CPTGraphHostingView类).
我有一个名为X的类来实现UICollectionViewDelegate和UICollectionViewDataSource.
在类X中,我构建了我的视图的每个单元格(在ViewDidLoad)Core-Plot Graph中,我有以下代码将图形链接到UICollectionViewCell
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString* cellId = @"ChartCollectionId";
iPadCellCollectionViewCell* cell = [self.theCollectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath];
MyChart* chart = [_charts objectAtIndex:indexPath.row];
cell.hostingView.hostedGraph = chart.barChart;
return cell;
Run Code Online (Sandbox Code Playgroud)
}
它工作正常,我的所有图表都正确显示在屏幕上.当用户滚动视图时,会出现问题,然后一个或多个单元格变为"空白".我真的不明白为什么.
我已经找到一个解决办法,而不是添加CPTGraphHostingView在UICollectionViewCell在界面生成器,我建立它自己和以前的代码变为:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString* cellId = @"ChartCollectionId";
iPadCellCollectionViewCell* cell = [self.theCollectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath];
[cell.contentView addSubview:[_hostingViews objectAtIndex:indexPath.row]]; …Run Code Online (Sandbox Code Playgroud) 我有一个基本网格UICollectionView.这是一个简单的2列,多行布局使用UICollectionViewDelegateFlowLayout.选择单元格后,我想调暗背景,将单元格浮动到屏幕中心,然后根据所选单元格设置工作流程.我很新UICollectionViews,而且我不确定最好的方法.
UICollectionView在选择单元格时,我应该有for 的自定义布局吗?
或者有一种方法可以动画选定的单元格,而无需创建新的布局
如果有人能让我朝着正确的方向前进,我想我会很好地研究如何执行它.
ios uicollectionview uicollectionviewcell uicollectionviewlayout
我有兴趣将collectionview作为集合视图单元的一部分,但由于某种原因无法弄清楚如何完成.我将在哪里实现细胞收集视图的必要方法?
我正在构建一个UICollectionView,我的自定义单元格将包含两个标签和一个图像.
每个图像都是异步下载的,因此在下载完成之前我不知道它的大小.下载后,我想调整每个单元格以重新布局它的内容和框架,以适应刚刚下载的图像的高度.
因为UICollectionViewLayout,我正在使用CHTCollectionViewWaterfallLayout
要异步下载图像我正在使用SDWebImage,如下所示:
[cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]
completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType)
{... some completion code here ...}];
Run Code Online (Sandbox Code Playgroud)
题:
UICollectionViewCell在下载图像后,正确调整每个大小的方法是什么?
我正在尝试使用所谓的"自我调整单元",这意味着:
estimatedItemSize上flowLayoutpreferredLayoutAttributesFittingAttributes细胞类例如:UICollectionView具有自动布局的自定义单元格
我需要这样的动态效果:http://www.teehanlax.com/blog/implementing-a-bouncy-uicollectionviewlayout-with-uikit-dynamics/
没有UIDynamic,它工作正常,但我需要UIDynamic.正如我所看到的那样,它会调用prepareLayout并且layoutAttributesForElementsInRect直到死亡,将会有太多_updateVisibleCellsNow排队等待.
我不知道如何解决这个问题,如果你看到,请帮助我.或者,如果我以错误的方式使用这些技术,请告诉我.
ios uicollectionview uicollectionviewcell uicollectionviewlayout uikit-dynamics
我希望显示尽可能多的数组collectionViewCells,buttons因为我的数组中有字符串.但是当我启动模拟器时,只有背景CollectionView但没有显示细胞.可能是什么错误?
这是CollectionViewController我附加到CollectionViewmain.storyboard中的代码:
class CollectionViewController: UICollectionViewController {
var Array = [String]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
Array = ["1","2","3","4","5"]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func collectionView(collectionView: UICollectionView, numberOfItemsSection section: Int) -> Int {
return Array.count
}
override func
collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
var …Run Code Online (Sandbox Code Playgroud) 当iOS 7.1发送我的viewController时:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
indexPath对象无法识别属性:item,section或row.期望值是section = 0,item = 0
调试器显示:
**indexPath NSIndexPath * 0xc000000000000016
NSObject
_indexes NSUInteger * NULL
*_indexes
_length
_reserved void * NULL
Run Code Online (Sandbox Code Playgroud)
日志报告:
(lldb) po indexPath
<NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}
(lldb) po indexPath.item
error: property 'item' not found on object of type 'NSIndexPath *'
error: 1 errors parsing expression
(lldb) po indexPath.row
error: property 'row' not found on object of type 'NSIndexPath *'
error: 1 errors parsing …Run Code Online (Sandbox Code Playgroud) iOS8.4.在设备上不是模拟器.
我得到了这个错误;
Assertion failure in -[UICollectionView _updateWithItems:tentativelyForReordering:], /SourceCache/UIKit/UIKit-3347.44.2/UICollectionView.m:4563
我打电话的时候
NSArray* array_indexPaths = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:1 inSection:0]];
[self.collectionView reloadItemsAtIndexPaths:indexPaths];
Run Code Online (Sandbox Code Playgroud)
我试过把上面的东西放在里面
[self.collectionView performBatchUpdates:^{
没有运气.
有没有其他人经历过这个或者知道为什么会这样?
ios ×10
iphone ×2
autolayout ×1
cptbarplot ×1
crash ×1
nsindexpath ×1
objective-c ×1
swift ×1
xcode ×1