質問編集履歴
3
書式の改善
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
添付した画像の枚数に応じて選択できる数を制限したい
|
1
|
+
Swift 添付した画像の枚数に応じて選択できる数を制限したい
|
body
CHANGED
File without changes
|
2
書式の改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -38,7 +38,6 @@
|
|
38
38
|
pickerController.maxSelectableCount = 4
|
39
39
|
}
|
40
40
|
pickerController.didSelectAssets = { [unowned self] (assets: [DKAsset]) in
|
41
|
-
print("ここ")
|
42
41
|
self.assets = assets
|
43
42
|
self.collectionView.reloadData()
|
44
43
|
|
@@ -60,11 +59,9 @@
|
|
60
59
|
cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CellImage", for: indexPath)
|
61
60
|
imageView = cell?.contentView.viewWithTag(1) as? UIImageView
|
62
61
|
}
|
63
|
-
//表示
|
64
62
|
if let imageView = imageView {
|
65
63
|
|
66
64
|
asset.fetchFullScreenImage(completeBlock: { image, info in
|
67
|
-
print("じゃここは?")
|
68
65
|
imageView.image = image
|
69
66
|
|
70
67
|
})
|
1
書式の改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -37,7 +37,42 @@
|
|
37
37
|
} else if assets == 1 {
|
38
38
|
pickerController.maxSelectableCount = 4
|
39
39
|
}
|
40
|
+
pickerController.didSelectAssets = { [unowned self] (assets: [DKAsset]) in
|
41
|
+
print("ここ")
|
42
|
+
self.assets = assets
|
43
|
+
self.collectionView.reloadData()
|
44
|
+
|
45
|
+
}
|
46
|
+
present(pickerController, animated: true, completion: nil)
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
51
|
+
return self.assets?.count ?? 0
|
52
|
+
}
|
53
|
+
|
54
|
+
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
55
|
+
let asset = self.assets![indexPath.row]
|
56
|
+
var cell: UICollectionViewCell?
|
57
|
+
var imageView: UIImageView?
|
58
|
+
|
59
|
+
if asset.type == .photo {
|
60
|
+
cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CellImage", for: indexPath)
|
61
|
+
imageView = cell?.contentView.viewWithTag(1) as? UIImageView
|
62
|
+
}
|
63
|
+
//表示
|
64
|
+
if let imageView = imageView {
|
65
|
+
|
66
|
+
asset.fetchFullScreenImage(completeBlock: { image, info in
|
67
|
+
print("じゃここは?")
|
68
|
+
imageView.image = image
|
69
|
+
|
70
|
+
})
|
71
|
+
}
|
72
|
+
return cell!
|
73
|
+
}
|
40
74
|
|
41
|
-
|
75
|
+
}
|
42
76
|
|
77
|
+
|
43
78
|
```
|