大家好我正在创建一个带有11个图像的仪表板的应用程序..
1是背景,1是划分按钮的线,9是带图像的按钮.
我尝试了几次自动约束,但我也尝试手动,我无法弄清楚如何正确设置约束.我也遵循了很多教程.如果您观看下面的图像,您可以看到特别是iPhone 4中的按钮/图像很奇怪!
我有UICollectionView
2个部分.我想在用户点击它时选择单元格.
每次用户点击单元格时,我的代码都会正确运行,单元格会变小,并且会在其中显示复选标记(imageView
我将其添加为单元格的子视图).问题是如果我在第一部分点击一个单元格,它会在第二部分中选择另一个单元格.这很奇怪,因为我使用了indexPath
.
这是我的代码:
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
// handle tap events
let cell = collectionView.cellForItemAtIndexPath(indexPath)
let centerCell = cell?.center
if cell!.frame.size.width == cellWidth {
cell?.frame.size.width = (cell?.frame.size.width)!/1.12
cell?.frame.size.height = (cell?.frame.size.height)!/1.12
cell?.center = centerCell!
let imageView = UIImageView()
imageView.image = MaterialIcon.check?.imageWithColor(MaterialColor.white)
imageView.backgroundColor = MaterialColor.blue.accent2
imageView.frame = CGRectMake(1, 1, 20, 20)
imageView.layer.cornerRadius = imageView.frame.height/2
imageView.clipsToBounds = true
if indexPath.section == 0 {
imageView.tag = indexPath.row+4000
} else {
imageView.tag = indexPath.row+5000
}
print("IMAGEVIEW …
Run Code Online (Sandbox Code Playgroud)