Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add images #12

Closed
iambenmitchell opened this issue Apr 18, 2020 · 4 comments
Closed

Cannot add images #12

iambenmitchell opened this issue Apr 18, 2020 · 4 comments

Comments

@iambenmitchell
Copy link

Hello, I am trying to make a TikTok style UI.

I have tried this:

struct ContentView: View {
     @State var index: Int = 0
   var body: some View {
            Pages(currentPage: $index, navigationOrientation: .vertical) {
                Image("ModelX")
            }
        }
    }

However I get this error: Cannot convert value of type 'Image' to closure result type '[AnyView]'

I have also tried doing this:

struct ContentView: View {
     @State var index: Int = 0
   var body: some View {
            Pages(currentPage: $index, navigationOrientation: .vertical) {
                NewsView()
            }
        }
    }

struct NewsView: View{
    var body: some View {
        Image("modelX")
    }
    
}

However I get the same error but lightly different: Cannot convert value of type 'NewsView' to closure result type '[AnyView]'

Anyhelp is appreciated, I am not a noob but I am new to swiftUI

@iambenmitchell
Copy link
Author

Solved: I am an idiot, I got this error before I added a second item.

You must have at least two items ie

Image("")
Image("")

I got thrown off because I usually stop as soon as I see an error

@nachonavarro
Copy link
Owner

No worries :)

As you can read in the docs, the Pages view needs more than one page. Otherwise the compiler treats what's inside Pages as a closure.

@iambenmitchell
Copy link
Author

No worries :)

As you can read in the docs, the Pages view needs more than one page. Otherwise the compiler treats what's inside Pages as a closure.

I am having another issue now where images don’t behave correctly: https://twitter.com/a_mrbenmitchell/status/1251582028606246914?s=21

@iambenmitchell
Copy link
Author

#13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants