0

I have a "DetailView" accessed from a list in "ContentView". In this DetialView, there is too much text, and I can't figure out how to add a ScrollView (or if that is the correct addition) while in the NavigationView. here you can see why I need a scroll

I've tried to add the ScrollView after NavigationView (above the VStack of information) without any luck.

struct DetailView: View {
    var selectedGrape: Grape

    var body: some View {

        return NavigationView {
            VStack {
                Text(selectedGrape.grapeName)
                    .font(.largeTitle)
                    .foregroundColor(.blue)

                Text("Characteristics")
                    .font(.title)
                    .fontWeight(.bold)
                    .padding(.top)
                Text(selectedGrape.grapeCharacteristics)


            }
        }

    }
}

It simply is unable to build

Gleb A.
  • 1,180
  • 15
  • 24
JTH
  • 1
  • 1
  • Possible duplicate of [Using Scroll View with Autolayout Swift](https://stackoverflow.com/questions/37223709/using-scroll-view-with-autolayout-swift) – Kate Orlova Jul 13 '19 at 11:03
  • I can't see that previous questions answer this problem since this is done in the new Swift 5.0 – JTH Jul 13 '19 at 11:09

1 Answers1

0

Why not:

NavigationView {
        ScrollView {
            VStack {
                Text("Title")
                    .font(.largeTitle)
                    .foregroundColor(.blue)

                Text("Headline")
                    .font(.title)
                    .fontWeight(.bold)
                    .padding(.top)

                Text("Body")
            }
        }
}
Infinity James
  • 4,667
  • 5
  • 23
  • 36
  • when I do that, the long text is put on a single very long horizontal line and I have to scroll quite a bit horizontally to see the rest of the VStack. I would want the text to limit itself in width to the width of the screen, be on multiple lines and make it so that the scroll was vertical instead of horizontal – JTH Jul 13 '19 at 14:04
  • @JTH What version of the Xcode Beta are you using? Beta 2 or Beta 3? If I remember correctly, Beta 2 had issues with `ScrollView` only scrolling horizontally, and Beta 3 supposedly fixed that issue. Fair warning, however - Beta 3 broke the ability to run SwiftUI projects on Mac, so if you do download it, you should probably also keep Beta 2 installed on your computer as well. – graycampbell Jul 14 '19 at 00:03