2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SwiftUIでNaivigationViewが重なったら

Last updated at Posted at 2020-05-26

##起きたこと
NavigationViewが重なっちゃった!
スクリーンショット 2020-05-26 13.41.42.jpg

##原因と対処法
NavigationViewが複数存在していることが原因です。
はじめのViewにのみNavigationView{}で囲むようにしましょう。

##ソースコード

import SwiftUI

struct test12: View {
    var body: some View {
        NavigationView{   //これだけでいい
            NavigationLink(destination: test13()){
        Text("Hello, World!")
            }
        }
    }
}

struct test13: View {
    var body: some View {
        NavigationView {   //これはいらない
        NavigationLink(destination: test14()) {
        Text(/"Hello, World!")
        }
        }
    }
}
struct test14: View {
    var body: some View {
        
            
        Text("Hello, World!")
        
    }
}
struct test12_Previews: PreviewProvider {
    static var previews: some View {
        test12()
    }
}

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?