Post

Replies

Boosts

Views

Activity

Reply to Keep ScrollView position when adding items on the top
But what about adding multiple items at the top of the list? I did that and the result was strange, when I start scrolling it couldn't scroll properly. We are developing something really important and we need that ability but Swiftui has a problem with it! struct SwiftUIView: View { @State var data: [String] = (0 ..< 25).map { String($0) } @State var dataID: String? var body: some View { ScrollView { VStack { Text("Header") LazyVStack { ForEach(data, id: \.self) { item in Color.red .frame(width: 100, height: 100) .overlay { Text("\(item)") .padding() .background() } } } .scrollTargetLayout() } } .scrollPosition(id: $dataID) .safeAreaInset(edge: .bottom) { HStack { Text("\(Text("Scrolled").bold()) \(dataIDText)") Spacer() Button { dataID = data.first } label: { Label("Top", systemImage: "arrow.up") } Button { dataID = data.last } label: { Label("Bottom", systemImage: "arrow.down") } Menu { Button("Batch Prepend") { let newDatas = (data.count ..< data.count + 6).map{"New Data \($0)"} newDatas.forEach { data in self.data.insert(data, at: 0) } // data.insert(contentsOf: newDatas, at: 0) // Does not have any difference. } Button("Prepend") { let next = "New Data 1" data.insert(next, at: 0) } Button("Append") { let next = String(data.count) data.append(next) } Button("Remove First") { data.removeFirst() } Button("Remove Last") { data.removeLast() } } label: { Label("More", systemImage: "ellipsis.circle") } } } } var dataIDText: String { dataID.map(String.init(describing:)) ?? "None" } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’23
Reply to SwiftUI list overlap navigationBar
I fixed the problem just by removing all unnecessary views around the List and just putting the pure view at the root of the view. Also, you need to be cautious about ZStack and so on. My piece of advice is that, commenting all the views and modifiers and then step by step uncomment the views until you can find the root of the problem.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’23
Reply to Showing sheet dismiss navigation view child
I've found a solution for that but I truly believe that it's a SwiftUI bug. You must move the navigation link to the upper parent and view. import SwiftUI struct ContentView: View {     @State     var shownextPage = false     var body: some View {         NavigationView{             ZStack{                 TabView{                     Tab1(shownextPage: $shownextPage)                         .tabItem({Text("tab1")})                     Tab2()                         .tabItem({Text("tab2")})                 }                 NavigationLink(destination: SecondView(), isActive: $shownextPage) {                     EmptyView()                 }             }             .navigationViewStyle(.stack)         }     } } struct Tab1: View {     @Binding     var shownextPage:Bool     var body: some View {         ZStack{             Button ("Next Page"){                 shownextPage = true             }         }     } } struct Tab2: View {     var body: some View {         Text("Tab 2 detail")     } } struct SecondView: View {     @State     var showSheet:Bool = false     var body: some View {         VStack{             Button {                 showSheet = true             } label: {                 Text("open Sheet")                     .padding()             }         }         .sheet(isPresented: $showSheet, onDismiss: nil) {             Text("hello in sheet")         }     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’21
Reply to Unable to Verify App: An internet connection is required to verify the trust of the developer' ... This app will not be available until verified.
Same issue did try all the things but it's not working! So annoying we cant test our application on our device
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’23
Reply to Strange behavior in split screen mode and data lost in iPadOS 16.1!
Finally, in iPadOS 17 beta 5, I tested it and it worked! Thanks for resolving this bug that had been causing me frustration for the past 2 years. I now realize it was not my fault. I believe it's important to extend this fix to older versions of iPadOS as well since 3-column apps are completely unusable on those versions.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to Keep ScrollView position when adding items on the top
But what about adding multiple items at the top of the list? I did that and the result was strange, when I start scrolling it couldn't scroll properly. We are developing something really important and we need that ability but Swiftui has a problem with it! struct SwiftUIView: View { @State var data: [String] = (0 ..< 25).map { String($0) } @State var dataID: String? var body: some View { ScrollView { VStack { Text("Header") LazyVStack { ForEach(data, id: \.self) { item in Color.red .frame(width: 100, height: 100) .overlay { Text("\(item)") .padding() .background() } } } .scrollTargetLayout() } } .scrollPosition(id: $dataID) .safeAreaInset(edge: .bottom) { HStack { Text("\(Text("Scrolled").bold()) \(dataIDText)") Spacer() Button { dataID = data.first } label: { Label("Top", systemImage: "arrow.up") } Button { dataID = data.last } label: { Label("Bottom", systemImage: "arrow.down") } Menu { Button("Batch Prepend") { let newDatas = (data.count ..< data.count + 6).map{"New Data \($0)"} newDatas.forEach { data in self.data.insert(data, at: 0) } // data.insert(contentsOf: newDatas, at: 0) // Does not have any difference. } Button("Prepend") { let next = "New Data 1" data.insert(next, at: 0) } Button("Append") { let next = String(data.count) data.append(next) } Button("Remove First") { data.removeFirst() } Button("Remove Last") { data.removeLast() } } label: { Label("More", systemImage: "ellipsis.circle") } } } } var dataIDText: String { dataID.map(String.init(describing:)) ?? "None" } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to Strange behavior in split screen mode and data lost in iPadOS 16.1!
I don't know what I should do to accept it as a bug. I reported it here and in the Bug Reporter app, but there is no hope of fixing this bug.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to Strange behavior in split screen mode and data lost in iPadOS 16.1!
After 4 months of waiting again no response from the Apple developer! This is a huge bug in iPadOs and even the newest version of the sample app that Apple provided has exactly the same bug. It's impossible to make an app for iPadOS to persist data with NavigationSplitView after going to the home screen.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Mar ’23
Reply to SwiftUI list overlap navigationBar
I fixed the problem just by removing all unnecessary views around the List and just putting the pure view at the root of the view. Also, you need to be cautious about ZStack and so on. My piece of advice is that, commenting all the views and modifiers and then step by step uncomment the views until you can find the root of the problem.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’23
Reply to Strange behavior in split screen mode and data lost in iPadOS 16.1!
With this link, you can realize what I'm talking about. https://youtu.be/WdPHHJvNcLQ
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to Showing sheet dismiss navigation view child
I've found a solution for that but I truly believe that it's a SwiftUI bug. You must move the navigation link to the upper parent and view. import SwiftUI struct ContentView: View {     @State     var shownextPage = false     var body: some View {         NavigationView{             ZStack{                 TabView{                     Tab1(shownextPage: $shownextPage)                         .tabItem({Text("tab1")})                     Tab2()                         .tabItem({Text("tab2")})                 }                 NavigationLink(destination: SecondView(), isActive: $shownextPage) {                     EmptyView()                 }             }             .navigationViewStyle(.stack)         }     } } struct Tab1: View {     @Binding     var shownextPage:Bool     var body: some View {         ZStack{             Button ("Next Page"){                 shownextPage = true             }         }     } } struct Tab2: View {     var body: some View {         Text("Tab 2 detail")     } } struct SecondView: View {     @State     var showSheet:Bool = false     var body: some View {         VStack{             Button {                 showSheet = true             } label: {                 Text("open Sheet")                     .padding()             }         }         .sheet(isPresented: $showSheet, onDismiss: nil) {             Text("hello in sheet")         }     } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’21
Reply to List with ForLoop animation collapse not working correctly on iOS 15
No one can help?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21