質問編集履歴

3

書式の改善

2021/02/10 07:49

投稿

konakizzi_mk
konakizzi_mk

スコア21

test CHANGED
@@ -1 +1 @@
1
- 添付した画像の枚数に応じて選択できる数を制限したい
1
+ Swift 添付した画像の枚数に応じて選択できる数を制限したい
test CHANGED
File without changes

2

書式の改善

2021/02/10 07:49

投稿

konakizzi_mk
konakizzi_mk

スコア21

test CHANGED
File without changes
test CHANGED
@@ -78,8 +78,6 @@
78
78
 
79
79
       pickerController.didSelectAssets = { [unowned self] (assets: [DKAsset]) in
80
80
 
81
- print("ここ")
82
-
83
81
  self.assets = assets
84
82
 
85
83
  self.collectionView.reloadData()
@@ -122,15 +120,11 @@
122
120
 
123
121
  }
124
122
 
125
- //表示
126
-
127
123
  if let imageView = imageView {
128
124
 
129
125
 
130
126
 
131
127
  asset.fetchFullScreenImage(completeBlock: { image, info in
132
-
133
- print("じゃここは?")
134
128
 
135
129
  imageView.image = image
136
130
 

1

書式の改善

2021/02/10 07:46

投稿

konakizzi_mk
konakizzi_mk

スコア21

test CHANGED
File without changes
test CHANGED
@@ -76,9 +76,79 @@
76
76
 
77
77
  }
78
78
 
79
+      pickerController.didSelectAssets = { [unowned self] (assets: [DKAsset]) in
80
+
81
+ print("ここ")
82
+
83
+ self.assets = assets
84
+
85
+ self.collectionView.reloadData()
86
+
87
+
88
+
89
+ }
90
+
91
+ present(pickerController, animated: true, completion: nil)
92
+
93
+ }
94
+
95
+
96
+
97
+
98
+
99
+ func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
100
+
101
+ return self.assets?.count ?? 0
102
+
103
+ }
104
+
105
+
106
+
107
+ func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
108
+
109
+ let asset = self.assets![indexPath.row]
110
+
111
+ var cell: UICollectionViewCell?
112
+
113
+ var imageView: UIImageView?
114
+
115
+
116
+
117
+ if asset.type == .photo {
118
+
119
+ cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CellImage", for: indexPath)
120
+
121
+ imageView = cell?.contentView.viewWithTag(1) as? UIImageView
122
+
123
+ }
124
+
125
+ //表示
126
+
127
+ if let imageView = imageView {
128
+
129
+
130
+
131
+ asset.fetchFullScreenImage(completeBlock: { image, info in
132
+
133
+ print("じゃここは?")
134
+
135
+ imageView.image = image
136
+
137
+
138
+
139
+ })
140
+
141
+ }
142
+
143
+ return cell!
144
+
145
+ }
79
146
 
80
147
 
148
+
81
- //略
149
+ }
150
+
151
+
82
152
 
83
153
 
84
154