回答編集履歴

2

コメント消し忘れ。

2016/07/26 05:33

投稿

fuzzball
fuzzball

スコア16731

test CHANGED
@@ -44,7 +44,7 @@
44
44
 
45
45
 
46
46
 
47
- //リクエスト(& requestID保存)
47
+ //リクエスト
48
48
 
49
49
  manager.requestImageForAsset(
50
50
 

1

ちっちゃいのください。

2016/07/26 05:33

投稿

fuzzball
fuzzball

スコア16731

test CHANGED
@@ -11,3 +11,83 @@
11
11
 
12
12
 
13
13
  他の原因、もしくは、他にも原因があるかも知れませんが。
14
+
15
+
16
+
17
+ # ただのメモリ不足?
18
+
19
+
20
+
21
+ 大きな画像を大量に読み込んでメモリ不足になっているのではないか?という推測。
22
+
23
+ 小さいサイズでリクエストするようにします。(requestID関係は一旦削除していいかも)
24
+
25
+
26
+
27
+ ```swift
28
+
29
+ override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
30
+
31
+ :
32
+
33
+ //imageviewにはcellのサイズを渡す
34
+
35
+ let imageview:UIImageView = UIImageView(frame: CGRectMake(1, 1, CGRectGetWidth(cell.frame)-2, CGRectGetHeight(cell.frame)-2))
36
+
37
+ //imageview.image = photo //ここでは設定しない
38
+
39
+ imageview.contentMode = .ScaleAspectFit //お好みで
40
+
41
+ imageview.clipsToBounds = true
42
+
43
+ cell.contentView.addSubview(imageview)
44
+
45
+
46
+
47
+ //リクエスト(& requestID保存)
48
+
49
+ manager.requestImageForAsset(
50
+
51
+ asset,
52
+
53
+ targetSize: imageview.frame.size, //imageviewのサイズでリクエスト
54
+
55
+ contentMode: .AspectFit, //imageviewに合わせる?
56
+
57
+ options: nil
58
+
59
+ ) { (image, info) -> Void in
60
+
61
+ //imageviewにセット
62
+
63
+ imageview.image = image //読み込んだ画像をセット
64
+
65
+ let degraded = (info![PHImageResultIsDegradedKey]?.boolValue)!
66
+
67
+ //print(image!.size, degraded)
68
+
69
+ if degraded {
70
+
71
+ //print(indexPath, "continue...")
72
+
73
+ }
74
+
75
+ else
76
+
77
+ {
78
+
79
+ //print(indexPath, "done")
80
+
81
+ }
82
+
83
+ }
84
+
85
+
86
+
87
+ return cell
88
+
89
+ }
90
+
91
+ ```
92
+
93
+