19.6 C
Canberra
Saturday, October 25, 2025

ios – SwiftUI TabView content material passing behind title


I’ve a SwiftUi Record the place every merchandise results in a TabView. When accessing the TabView and scrolling down, the content material of the Tab cross behind the present view toolbar.

See instance

import SwiftUI
import SwiftData

struct ContentView: View {
  @Question non-public var objects: [Item]
  
  non-public var itemsBis: [String] {
    Array(repeating: "Merchandise ", rely: 100)
  }
  
  var physique: some View {
    NavigationSplitView {
      Record {
        ForEach(objects) { merchandise in
          NavigationLink {
            TabView {
              Tab("Tab 1", systemImage: "home") {
                Type {
                  ForEach(Array(itemsBis.enumerated()), id: .offset) { index, merchandise in
                    Textual content("(merchandise) (index + 1)")
                  }
                }
              }
              Tab("Tab 2", systemImage: "circle") {
                Type {
                  ForEach(Array(itemsBis.enumerated()), id: .offset) { index, merchandise in
                    Textual content("(merchandise) (index + 1)")
                  }
                }
                
              }
              Tab("Tab 3", systemImage: "gear") {
                Type {
                  ForEach(Array(itemsBis.enumerated()), id: .offset) { index, merchandise in
                    Textual content("(merchandise) (index + 1)")
                  }
                }
              }
            }
          } label: {
            Textual content(merchandise.timestamp, format: Date.FormatStyle(date: .numeric, time: .normal))
          }
        }
      }
    } element: {
      Textual content("Choose an merchandise")
    }
  }
}

#Preview {
  ContentView()
    .modelContainer(for: Merchandise.self, inMemory: true)
}

Finally after a number of scrolls or switching tab, the content material will show accurately.

What adjustments ought to I carry to keep away from this habits?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

[td_block_social_counter facebook="tagdiv" twitter="tagdivofficial" youtube="tagdiv" style="style8 td-social-boxed td-social-font-icons" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjM4IiwiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMzAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" custom_title="Stay Connected" block_template_id="td_block_template_8" f_header_font_family="712" f_header_font_transform="uppercase" f_header_font_weight="500" f_header_font_size="17" border_color="#dd3333"]
- Advertisement -spot_img

Latest Articles