回答編集履歴

5

修正

2018/06/13 10:15

投稿

masimasi
masimasi

スコア32

test CHANGED
@@ -5,6 +5,10 @@
5
5
  結果として以下の書き方でうまくいったのですが
6
6
 
7
7
  なぜこれでうまくいくのかよくわからないです。
8
+
9
+
10
+
11
+ なぜこれで動くのでしょうか?不思議です。
8
12
 
9
13
 
10
14
 

4

修正

2018/06/13 10:15

投稿

masimasi
masimasi

スコア32

test CHANGED
@@ -9,6 +9,12 @@
9
9
 
10
10
 
11
11
  とりあえず動きました
12
+
13
+
14
+
15
+ 参考
16
+
17
+ https://qiita.com/fromage-blanc/items/f33be78405dfa9f79f30
12
18
 
13
19
 
14
20
 

3

修正

2018/06/13 10:13

投稿

masimasi
masimasi

スコア32

test CHANGED
@@ -1,13 +1,47 @@
1
+ dismissする前に 後ろのtabbarを操作すればよいという考えでやってみました。
2
+
3
+ tabbar 遷移 コード のサンプルをコピーしたところ
4
+
1
- !!
5
+ 結果として以下の書き方くいっのですが
6
+
7
+ なぜこれでうまくいくのかよくわからないです。
2
8
 
3
9
 
4
10
 
5
- dismissするまに 後ろのtabbarをpresentingViewControllerで操作することで解決できました
11
+ とりあず動きました
6
12
 
7
13
 
8
14
 
15
+
16
+
17
+ ```ここに言語を入力
18
+
19
+ // タブバーのインスタンスを取得
20
+
9
- let parentVC = presentingViewController as! MainTabBarController
21
+ if let tabvc = UIApplication.shared.keyWindow?.rootViewController as? UITabBarController {
22
+
23
+ //左から0番目のタブアイコンを選択状態にする(0が一番左)
24
+
25
+ DispatchQueue.main.async {
26
+
27
+ tabvc.selectedIndex = 0
28
+
29
+ }
30
+
31
+ }
10
32
 
11
33
 
12
34
 
35
+ //移動先ViewControllerのインスタンスを取得(ストーリーボードIDから)
36
+
37
+ let storyboard = UIStoryboard(name: "Main", bundle: nil)
38
+
39
+ let dstView = storyboard.instantiateViewController(withIdentifier: "MainTabBarController")
40
+
41
+ self.tabBarController?.navigationController?.present(dstView, animated: true, completion: nil)
42
+
43
+
44
+
13
- でもこれがベストかはわからないです
45
+ self.dismiss(animated: true, completion: nil)
46
+
47
+ ```

2

文字

2018/06/13 10:09

投稿

masimasi
masimasi

スコア32

test CHANGED
@@ -8,12 +8,6 @@
8
8
 
9
9
  let parentVC = presentingViewController as! MainTabBarController
10
10
 
11
- let storyboard: UIStoryboard = parentVC.storyboard!
12
-
13
- let backTop = storyboard.instantiateViewController(withIdentifier: "MainTabBarController")
14
-
15
- parentVC.present(backTop, animated: true, completion: nil)
16
-
17
11
 
18
12
 
19
13
  でもこれがベストかはわからないです

1

文字修正

2018/06/13 03:53

投稿

masimasi
masimasi

スコア32

test CHANGED
@@ -16,4 +16,4 @@
16
16
 
17
17
 
18
18
 
19
- でもれがベストかはわからないです
19
+ でもれがベストかはわからないです