回答編集履歴
1
コメントへの返信。
test
CHANGED
@@ -1 +1,93 @@
|
|
1
1
|
Swift3を勉強する気がないのであれば、Swift2で開発すればいいのではないでしょうか?
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
【追記】
|
6
|
+
|
7
|
+
コメントへの返信ですが、見にくくなるのでこちらに書きます。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
リファレンスを見る/探すのは基本です。
|
12
|
+
|
13
|
+
(いちいちリンクを張っていますが、Xcodeで見ることが出来る情報です)
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
### indexPath
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
> let indexPath = NSIndexPath(forItem:count, inSection:0) // <= ここでエラー
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
itemとsectionによる初期化は [NSIndexPath(item:section:)](https://developer.apple.com/documentation/foundation/nsindexpath/1526053-init) ですので、
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
```swift
|
30
|
+
|
31
|
+
let indexPath = NSIndexPath(item: count, section: 0)
|
32
|
+
|
33
|
+
```
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
となりますが、[UICollectionViewLayoutAttributes(forCellWith:)](https://developer.apple.com/documentation/uikit/uicollectionviewlayoutattributes/1617759-init)に渡すのはNSIndexPathではなくIndexPathに変わっていますので[IndexPath(item:section:)](https://developer.apple.com/documentation/foundation/indexpath/1924279-init)を使います。
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
```swift
|
42
|
+
|
43
|
+
let indexPath = IndexPath(item: count, section: 0)
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
### collectionViewContentSize
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
> override func collectionViewContentSize() -> CGSize { // <= ここでエラー
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
[collectionViewContentSize](https://developer.apple.com/documentation/uikit/uicollectionviewlayout/1617796-collectionviewcontentsize)を見ると、func(関数)ではなくvar(変数/プロパティ)に変わっていますので、
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
```swift
|
62
|
+
|
63
|
+
override var collectionViewContentSize: CGSize {
|
64
|
+
|
65
|
+
//(中略)
|
66
|
+
|
67
|
+
return CGSize(width:allWidth, height:allHeight)
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
```
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
でいけると思います。
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
### Storyboard
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
> Storyboard=>Collection View=>Layoutをカスタムにして、Classにわりあてようとしたのですが、
|
84
|
+
|
85
|
+
でませんでした。
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
TextLayoutを割り当てようとしているんですよね?普通なら、Classのところに`T`と入力した時点で補完されるはずですが‥。ひとまず、エラーが無くなってからもう一度試してみて下さい。
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|