teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

修正

2018/05/17 02:27

投稿

po_tato
po_tato

スコア97

title CHANGED
File without changes
body CHANGED
@@ -22,7 +22,7 @@
22
22
  func tableView(_ table: UITableView, didSelectRowAt indexPath: IndexPath) {
23
23
 
24
24
  if status[indexPath.row] == 0 {
25
-
25
+ print("アイウエオ")
26
26
  let alertController = UIAlertController(title: "", message: "遷移しますか?", preferredStyle: UIAlertControllerStyle.alert)
27
27
  let actionOK = UIAlertAction(title: "OK", style: UIAlertActionStyle.default ,handler:{
28
28
  (action:UIAlertAction!) -> Void in
@@ -46,6 +46,7 @@
46
46
 
47
47
  self.present(alertController, animated: true, completion: nil)//ここの行
48
48
  }else{
49
+      print("カキクケコ")
49
50
  //ここから追加部分
50
51
       self.appDelegate.id = self.user_id[indexPath.row]
51
52
 

3

修正

2018/05/17 02:26

投稿

po_tato
po_tato

スコア97

title CHANGED
File without changes
body CHANGED
@@ -45,7 +45,7 @@
45
45
  alertController.addAction(cancelAction)
46
46
 
47
47
  self.present(alertController, animated: true, completion: nil)//ここの行
48
- }
48
+ }else{
49
49
  //ここから追加部分
50
50
       self.appDelegate.id = self.user_id[indexPath.row]
51
51
 
@@ -53,6 +53,7 @@
53
53
  let lp = storyboard.instantiateViewController(withIdentifier: "second") as! SecondViewController
54
54
  lp.modalTransitionStyle = UIModalTransitionStyle.partialCurl
55
55
  self.navigationController?.pushViewController(lp, animated: true)
56
+ }
56
57
  }
57
58
 
58
59
  ```

2

本文追記

2018/05/17 02:13

投稿

po_tato
po_tato

スコア97

title CHANGED
File without changes
body CHANGED
@@ -7,7 +7,7 @@
7
7
  すると[リンク内容](http://blogios.stack3.net/archives/2409)こちらのサイトに同じような現象が書かれていました。ですが、数年前の記事であること、objective-cであることなどでうまくいきませんでした。
8
8
 
9
9
  ソースを下記に記載します。
10
- 最後の行をこのように変えると良いというのを海外のサイトで目にしたので試しましたが、
10
+ コメントアウト部分"ここの"をこのように変えると良いというのを海外のサイトで目にしたので試しましたが、
11
11
  アラートが出ずに、次の画面に遷移していまいそこで落ちてしまいます。
12
12
  解決策を知っている方はおられないでしょうか?
13
13
 
@@ -27,6 +27,8 @@
27
27
  let actionOK = UIAlertAction(title: "OK", style: UIAlertActionStyle.default ,handler:{
28
28
  (action:UIAlertAction!) -> Void in
29
29
 
30
+ self.appDelegate.id = self.user_id[indexPath.row] //この行追加
31
+
30
32
  let storyboard:UIStoryboard = self.storyboard!
31
33
  let lp = storyboard.instantiateViewController(withIdentifier: "second") as! SecondViewController
32
34
  lp.modalTransitionStyle = UIModalTransitionStyle.partialCurl
@@ -42,8 +44,15 @@
42
44
  alertController.addAction(actionOK)
43
45
  alertController.addAction(cancelAction)
44
46
 
45
- self.present(alertController, animated: true, completion: nil)//最後の行
47
+ self.present(alertController, animated: true, completion: nil)//ここの行
46
48
  }
49
+ //ここから追加部分
50
+      self.appDelegate.id = self.user_id[indexPath.row]
51
+
52
+ let storyboard:UIStoryboard = self.storyboard!
53
+ let lp = storyboard.instantiateViewController(withIdentifier: "second") as! SecondViewController
54
+ lp.modalTransitionStyle = UIModalTransitionStyle.partialCurl
55
+ self.navigationController?.pushViewController(lp, animated: true)
47
56
  }
48
57
 
49
58
  ```

1

コード修正

2018/05/17 01:37

投稿

po_tato
po_tato

スコア97

title CHANGED
File without changes
body CHANGED
@@ -18,8 +18,8 @@
18
18
  ```
19
19
 
20
20
  ```
21
- {
22
21
 
22
+ func tableView(_ table: UITableView, didSelectRowAt indexPath: IndexPath) {
23
23
 
24
24
  if status[indexPath.row] == 0 {
25
25
 
@@ -45,4 +45,5 @@
45
45
  self.present(alertController, animated: true, completion: nil)//最後の行
46
46
  }
47
47
  }
48
+
48
49
  ```