質問編集履歴

1

追記

2022/09/12 11:41

投稿

tomotomo2
tomotomo2

スコア2

test CHANGED
File without changes
test CHANGED
@@ -39,7 +39,7 @@
39
39
  static let testUIViewController = TestUIViewController()
40
40
 
41
41
  func presenter(){
42
- let storyboard: UIStoryboard = self.storyboard!
42
+ let storyboard = UIStoryboard(name: "Main", bundle: nil)
43
43
  let nextVC = storyboard.instantiateViewController(withIdentifier: "nextVC") as! NextViewController
44
44
  self.present(nextVC, animated: true, completion: nil)
45
45
   print("UI遷移しました!")
@@ -48,8 +48,20 @@
48
48
  ```
49
49
  どうすれば、UIView→UIViewControllerをpresentでUI遷移できるのでしょうか?
50
50
 
51
+ ### 補足情報
52
+ ログを見る限り、presenter()が発火してはいるようです。
53
+ TestUIViewControllerとNextViewControllerは、main.storyboad内にありますが、階層にないと言われています。
54
+ UIViewは、test.xibに紐付いています。
55
+ ```
56
+ Attempt to present <testproject.NextViewController: 0x103853e80>
57
+ on <testproject.TestUIViewController: 0x1050a9a00>
58
+ (from <testproject.TestUIViewController: 0x1050a9a00>)
59
+ whose view is not in the window hierarchy.
51
60
 
61
+ UI遷移しました!
62
+ ```
63
+
52
- ### 補足情報
64
+ ### 最後に
53
65
  かなりハマっています。UIView→UIViewControllerを行なっている記事があまり見受けられません。
54
66
  「そもそも、できない」という気すらしてきました。
55
67
  できないならできないという情報だけでも、いただけると非常にありがたいです。