14

I'm new to swiftUI and just trying to figure out the basics. I'm simply trying to create a new view and a button that will move to it.

When I use the code below, an error appears: "Use of unresolved identifier 'NavigationButton'" despite that being generated by Xcode.

import SwiftUI

struct HomeView: View {

    var body: some View{
        NavigationView {
            NavigationButton(destination: NextView()) {
                Text("Navigate 1")}
        }
    }
}
Mojtaba Hosseini
  • 95,414
  • 31
  • 268
  • 278
Hubert Rzeminski
  • 469
  • 4
  • 15

2 Answers2

44

NavigationButton changed to NavigationLink for a while now. So replace it and use it.

Mojtaba Hosseini
  • 95,414
  • 31
  • 268
  • 278
3

NavigationLink replace NavigationButton, The code below is update for WWDC 2019 Introducing SwiftUI: Building Your First App

struct RoomCell: View {
    let room: Room

    var body: some View {
        NavigationLink(destination: RoomDetail(room: room)) {
            Image(room.thumbnailName)
                .cornerRadius(8)
            VStack(alignment: .leading) {
                Text(room.name)
                Text("\(room.capacity) people")
                    .font(.subheadline)
                    .foregroundColor(.secondary)
            }
        }
    }
}
Zgpeace
  • 3,927
  • 33
  • 31