回答編集履歴

5

s修正

2016/08/08 23:41

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -67,3 +67,11 @@
67
67
 
68
68
 
69
69
  [teratail_43621 サンプル](https://github.com/KentarouKanno/teratail_43621)
70
+
71
+
72
+
73
+ > func collectionView(collectionView: UICollectionView, didSelectItem・・・というのはセルをタッチした時のプログラムですよね? 教えてもらったプログラムの中身をprintに変えてみてセルを押してもprintが実行されなかったのは自分のsegueの設定に問題があるのではなくプログラミング自体になにか問題があるのでしょうか。
74
+
75
+
76
+
77
+ こちらは`collectionView`の`delegate`を`self`に設定していないからだと思われます。

4

修正

2016/08/08 23:41

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -55,3 +55,15 @@
55
55
  }
56
56
 
57
57
  ```
58
+
59
+
60
+
61
+ ---
62
+
63
+
64
+
65
+ 回答を踏まえて`vc1`と`vc2`はModai表示でそれ以外は汎用の`DetailViewController`にしてみました、以下からダウンロードして試してみてください。
66
+
67
+
68
+
69
+ [teratail_43621 サンプル](https://github.com/KentarouKanno/teratail_43621)

3

修正

2016/08/08 23:36

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -1,4 +1,4 @@
1
- 前提として`Storyboard`で`Segue`を結び`Segue Identifier`を設定していることがあると思います。
1
+ 前提として`Storyboard`で`Segue`を結び`Segue Identifier`を設定している必要があます。
2
2
 
3
3
  そこまで準備ができていたら以下の方法で画面遷移ができると思います。
4
4
 

2

修正

2016/08/07 23:08

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -1,4 +1,4 @@
1
- 前提として`Storyboard`で`Segue`び`Segue Identifier`を設定していることがあると思います。
1
+ 前提として`Storyboard`で`Segue`結び`Segue Identifier`を設定していることがあると思います。
2
2
 
3
3
  そこまで準備ができていたら以下の方法で画面遷移ができると思います。
4
4
 
@@ -26,7 +26,7 @@
26
26
 
27
27
 
28
28
 
29
- 後は汎用的な詳細画面に情報を渡して表示するも可能です。
29
+ 後は汎用的な詳細画面に情報を渡して表示する場合は以下の様になる思います。
30
30
 
31
31
 
32
32
 

1

修正

2016/08/07 22:16

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -23,3 +23,35 @@
23
23
  }
24
24
 
25
25
  ```
26
+
27
+
28
+
29
+ 後は汎用的な詳細画面に情報を渡して表示することも可能です。
30
+
31
+
32
+
33
+ ```swift
34
+
35
+ func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
36
+
37
+
38
+
39
+ performSegueWithIdentifier("detail", sender: photos[indexPath.row])
40
+
41
+ }
42
+
43
+
44
+
45
+ override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
46
+
47
+
48
+
49
+ if let detail = segue.destinationViewController as? DetailViewController {
50
+
51
+ detail.detailLabelString = sender as? String
52
+
53
+ }
54
+
55
+ }
56
+
57
+ ```