fermoya / SwiftUIPager

Native Pager in SwiftUI
MIT License
1.27k stars 166 forks source link

[BUG] The content of Scrollview cannot be clicked on Xcode 11 #80

Closed Atlands closed 4 years ago

Atlands commented 4 years ago

Pager contains a Scrollview and the Scrollview content is not large enough to cover the entire screen. Starting from the second page, clicking Scrollview has no effect, However, dragging Scrollview and clicking again will trigger the event correctly

import SwiftUI
import SwiftUIPager

struct UIttt: View {
    @State var currentPage = 0
    @State var a = 0
    var body: some View {
        VStack {
            Text("Hello, World! \(a)")
            Pager(page: $currentPage, data: Array(0..<10), id: \.self){ i in
                ScrollView {
                    Text("Hello, World!  Hello, World!  Hello, World!  Hello, World! Hello, World! Hello, World! Hello, World! Hello, World! Hello, World! Hello, World! Hello, World! Hello, World! \n\(self.a)")
                        .onTapGesture {
                            self.a = self.a + 1
                    }
                }
            }
        }
    }
}

struct UIttt_Previews: PreviewProvider {
    static var previews: some View {
        UIttt()
    }
}

1jdjs3im89082

fermoya commented 4 years ago

Hi @Atlands , the content is not the problem, if you use borders you'll see that the content size doesn't change from one page to the other.

I'll take a look but most probably you'll need to add/change some modifier to your page

fermoya commented 4 years ago

@Atlands I just tested this on Xcode 12 b3 and this has been fixed for SwiftUI 2.0 so it seems that it's an issue of the ScrollView. issue-80

Don't forget Pager comes with pagingPriority modifier that could be useful when a ScrollView is embedded.

PS: I'd appreciate if you star the repo in case you like the framework.

Atlands commented 4 years ago

@Atlands I just tested this on Xcode 12 b3 and this has been fixed for SwiftUI 2.0 so it seems that it's an issue of the ScrollView. issue-80

Don't forget Pager comes with pagingPriority modifier that could be useful when a ScrollView is embedded.

PS: I'd appreciate if you star the repo in case you like the framework.

Hi @fermoya , Can you send me a copy of your successful code? I used the property (. Pagingpriority) without effect. Maybe I missed something

fermoya commented 4 years ago

@Atlands just run the code you shared on Xcode 12 beta 3, that’s your “successful” code

Atlands commented 4 years ago

@fermoya Oh,thanks,I'm using Xcode Version 11.6

fermoya commented 4 years ago

@Atlands I've tried with both and whereas on Xcode 11.6 it doesn’t work and you have to scroll as you described to make the Text hittable, this isn’t try on Xcode 12. When this happens, I always assume it’s a SwiftUI issue as this kit is still very new.

I’ve checked the content by drawing borders and as I mentioned, the content is correct so it seems to be an issue with ScrollView