Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved identifier NavigationButton error

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")}
        }
    }
}
like image 455
Hubert Rzeminski Avatar asked Aug 22 '19 18:08

Hubert Rzeminski


2 Answers

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

like image 73
Mojtaba Hosseini Avatar answered Nov 20 '22 22:11

Mojtaba Hosseini


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)
            }
        }
    }
}
like image 3
Zgpeace Avatar answered Nov 20 '22 23:11

Zgpeace