在Xcode 6中,当我尝试将图像视图固定到边缘时UICollectionViewCell,自动布局会创建-8.0的约束.改变了什么?我试图找到发行说明或文档更新,但没有看到任何东西.



为什么会发生这种情况?边缘到边缘内容的首选方法是什么?
我有一个集合视图,它被设置为单个水平行单元格.它抛出以下约束错误(我正在使用AutoLayout):
未定义UICollectionViewFlowLayout的行为,因为项高度必须小于UICollectionView的高度减去截面插入顶部和底部值,减去内容插入顶部和底部值.
我用Google搜索并查看了SO,并且每个人都建议通过简单地覆盖UIScrollViewDelegate方法来修复它:
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
// iPhone 6+ device width handler
CGFloat multiplier = (screenWidth > kNumberOfCellsWidthThreshold) ? 4 : 3;
CGFloat size = screenWidth / multiplier;
return CGSizeMake(size, size);
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsMake(0, 0, 0, 0);
}
Run Code Online (Sandbox Code Playgroud)
但它仍然无法正常工作.尽管我将细胞设置为与容器相同的高度,但细胞高度比它的容器高,这似乎是一种愚蠢的行为.这是错误的其余部分:
相关的UICollectionViewFlowLayout实例是UICollectionViewFlowLayout:0x7fa6943e7760,它附加到MyCollectionView:0x7fa69581f200; baseClass = UICollectionView;
frame =(0 0; 375 98); clipsToBounds = YES; autoresize = RM + BM; layer = CALayer:0x7fa694315a60; contentOffset:{0,0}; contentSize:{0,134}
手动将单元格设置为一个非常小的尺寸(例如,size - 50.0似乎工作,但为什么我不能将单元格大小设置为与其容器相同的高度?
objective-c ios autolayout uicollectionview uicollectionviewlayout
我正在以编程方式创建tableviews和单元格.tableview单元格分隔符在iOS 8中移动,

即使我已经设定:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return kSomeNumber;
}
Run Code Online (Sandbox Code Playgroud)
我的应用程序是ios7,我的手机是ios8.可能是什么问题呢?我不能使用仅适用于ios8的cell.layoutMargins
我在定制我的手机时遇到了一些问题;
你可以看到分隔线没有到达单元格的左边界,我想这样做.我找到了这些:
任何人都可以帮我翻译快速代码吗?
所以令我惊讶的是,我没有在网络上找到任何关于这个特定问题的内容.我正在尝试将listview分隔符插入为全宽.我发现这个文档的实现代码如下,在这里.但是我不清楚如何为列表视图执行此操作?我正在使用Xamarin Forms listview,尝试在iOS上完成此操作.我想我必须编写一个自定义渲染器,因为在listview的表单上没有(公开暴露的)属性.
这是我在列表视图中发生的好照片,尽管显示的图像来自关于tableview的SO问题,而不是listview,但问题似乎是相同的.
我有一个 UITableView,其框架设置为父视图的框架大小。表格视图在 iPhone 上显示得很好。但是,在 iPad 上,它的两侧都有这么厚的边距。
如果我选择单元格,它会显示表格确实跨越了整个宽度。然而,分隔符似乎更小。我曾尝试将 layoutMargins 设置为零,但没有效果。这是我将它添加到我的视图的方法:
self.optionsView = UITableView()
self.optionsView.delegate = self
self.optionsView.dataSource = self
self.optionsView.hidden = true
self.optionsView.frame.origin = CGPoint(x: view.frame.size.width + 30, y: 0)
self.optionsView.frame.size = view.frame.size
self.optionsView.layer.shadowColor = Palette.shadowColor.CGColor
self.optionsView.layer.shadowRadius = 10.0
self.optionsView.layer.shadowOpacity = 0.3
self.optionsView.clipsToBounds = false
view.addSubview(optionsView)
Run Code Online (Sandbox Code Playgroud)
知道这里出了什么问题吗?
我知道这个问题已经过时了,所以这里已经发布了很多答案.
问题是,iPhone的解决方案正常运行.但是在使用iPad时,我仍然面临着一些问题.
请参阅以下图像(第一个是纵向模式,第二个是横向模式).
我在视图控制器中使用了下面的代码,在那里我编写了表视图的委托方法.
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[tableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[tableView setLayoutMargins:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
Run Code Online (Sandbox Code Playgroud)
题:
有没有办法在iPad中删除表格视图分隔符的左侧空白区域?我应该在iPhone的工作代码之外加入任何额外的支票吗?
困惑!!
ios ×3
ios8 ×3
uitableview ×3
autolayout ×2
objective-c ×2
separator ×2
cell ×1
delegates ×1
ios9 ×1
ipad ×1
listview ×1
swift ×1
xamarin ×1
xamarin.ios ×1
xcode6 ×1