Search results for

column

2,047 results found

Post

Replies

Boosts

Views

Activity

SwiftUI - Drag gesture blocks scroll gesture only on iPhone 11
I'm pretty new to Swift and SwiftUI. I'm making my first app for sorting a gallery with some extra features. I was using my own iPhone for testing and just started testing my app on other Apple products. Everything works fine on iPad Air M1, iPhone 15 Pro, iPhone 15 Pro Max, iPhone 13, iPhone XS (Simulator), and iPhone 11 Pro (Simulator). However, when I tried to show my app to a family member with an iPhone 11, I came across an issue. Issue Description: My app takes all photos from iPhone's native gallery, then you can sort it by some spesific filters and delete pictures. It just looks like the native gallery. (I can add photos later if needed) You can just scroll the gallery by swiping up and down. You can press the select button and start selecting pictures to delete. I recently added a drag-to-select-multiple-pictures feature. This makes it feel more like the native iOS experience, eliminating the need to tap each picture individually. However, on the iPhone 11, the moment you open the app, you can't scro
1
0
746
Jan ’25
Driving NavigationSplitView with something other than List?
Is it possible to drive NavigationSplitView navigation with a view in sidebar (left column) that is not a List? All examples that I have seen from this year only contain List in sidebar. I ask this because I would like to have a more complex layout in sidebar (or first view on iOS) that contains a mix of elements, some of them non-interactive and not targeting navigation. Here’s what I would like to do: import SwiftUI struct Thing: Identifiable, Hashable { let id: UUID let name: String } struct ContentView: View { let things: [Thing] @State private var selectedThingId: UUID? var body: some View { NavigationSplitView { ScrollView(.vertical) { VStack { ForEach(things) { thing in Button(Thing: (thing.name) ( selectedThingId == thing.id ? selected : )) { selectedThingId = thing.id } } SomeOtherViewHere() Button(Navigate to something else) { selectedThingId = someSpecificId } } } } detail: { // ZStack is workaround for known SDK bug ZStack { if let selectedThingId { Text(There is a thing ID: (selectedThi
13
0
6.9k
Apr ’23
VStack Alignment Issue
Hi Apple developer, I'm totally new in the development world using SwiftUI with just a little experience of Flutter. Currently I'm struggling with the combination of VStack and the alignment of the sub views. I'm using a LazyVGrid with multiple Rectangles and overlays inside. The overlay contains a VStack with a leading alignment. And here is the problem. I framed them with a border to visualize the limits of these views. But it seams, that the leading alignment is not working properly. There is a large gap on the left side of the Image() and Text() views and I don't know why. I'm very happy for any advice. Here is my code of this view. Thanks a lot! import SwiftUI import SwiftData extension UIScreen { static let screenWidth: CGFloat = UIScreen.main.bounds.size.width static let screenHeight: CGFloat = UIScreen.main.bounds.size.height static let screenSize: CGSize = UIScreen.main.bounds.size } struct TestView: View { let constants: Constants = Constants() let columnCount: Int = 2 let gridSpacing: CGFloat = 10
Topic: UI Frameworks SubTopic: SwiftUI
1
0
350
Jan ’25
iPadOS 18 TabView conflicts with NavigationSplitView
If you use the new TabView in conjunction with .tabViewStyle(.sidebarAdaptable) and have a NavigationSplitView in the tabs, the result is a very confusing user experience. When the TabView is displayed as tabs, there are two sidebar buttons. The left one closes/opens the sidebar of the view of the selected tab. The sidebar button of the Top-TabView closes/opens the sidebar for customizing the tabbar. However, this sidebar overlays the sidebar of the selected tab. To be able to use the underlying sidebar again, the user must actively close the TabView sidebar again (turn it into the top tabbar) Has anyone found ways to improve this behavior, or is this wrong by design? My expected behavior would be: If you use the new TabView with .tabViewStyle(.sidebarAdaptable) and have a two column NavigationSplitView in a tab, it automatically becomes a three column view when the top tabbar becomes a sidebar. import SwiftUI struct ContentView: View { var body: some View { TabView { Tab(Home, systemImage:
5
0
1.3k
Aug ’24
SwiftUI - Drag gesture blocks scroll gesture only on iPhone 11
I'm pretty new to Swift and SwiftUI. I'm making my first app for sorting a gallery with some extra features. I was using my own iPhone for testing and just started testing my app on other Apple products. Everything works fine on iPad Air M1, iPhone 15 Pro, iPhone 15 Pro Max, iPhone 13, iPhone XS (Simulator), and iPhone 11 Pro (Simulator). However, when I tried to show my app to a family member with an iPhone 11, I came across an issue. Issue Description: My app takes all photos from iPhone's native gallery, then you can sort it by some spesific filters and delete pictures. It just looks like the native gallery. (I can add photos later if needed) You can just scroll the gallery by swiping up and down. You can press the select button and start selecting pictures to delete. I recently added a drag-to-select-multiple-pictures feature. This makes it feel more like the native iOS experience, eliminating the need to tap each picture individually. However, on the iPhone 11, the moment you open the app, you can't scro
2
0
295
Jan ’25
Reply to SwiftUI Gestures prevent scrolling with iOS 18
I also have a similar issue. I'm pretty new to swift so there might be some messy code private var mediaGridView: some View { ScrollView { RefreshControl(coordinateSpace: .named(refresh)) { //some code here } LazyVGrid(columns: gridColumns) { //some code here } .padding(.horizontal, 2) .coordinateSpace(name: grid) .onPreferenceChange(ItemBoundsPreferenceKey.self) { //some code here } .gesture( DragGesture(minimumDistance: 0) .onChanged { gesture in if isSelectionMode { let location = gesture.location if !isDragging { startDragging(at: location, in: itemBounds) } updateSelection(at: location, in: itemBounds) } } .onEnded { _ in endDragging() } ) } .coordinateSpace(name: refresh) } First I catched the issue on an iPhone 11 test device. iPhone 11 on simulator with ios 18 also have this problem while 17.5 simulator won't. If I change .gesture() to .simultaneousGesture() vertical scrolling starts to work again but now scroll also works while dragging my finger so everything on the screen starts to dance.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’25
CoreData + CloudKit
I am having problems when I first loads the app. The time it takes for the Items to be sync from my CloudKit to my local CoreData is too long. Code I have the model below defined by my CoreData. public extension Item { @nonobjc class func fetchRequest() -> NSFetchRequest { NSFetchRequest(entityName: Item) } @NSManaged var createdAt: Date? @NSManaged var id: UUID? @NSManaged var image: Data? @NSManaged var usdz: Data? @NSManaged var characteristics: NSSet? @NSManaged var parent: SomeParent? } image and usdz columns are both marked as BinaryData and Attribute Allows External Storage is also selected. I made a Few tests loading the data when the app is downloaded for the first time. I am loading on my view using the below code: @FetchRequest( sortDescriptors: [NSSortDescriptor(keyPath: Item.createdAt, ascending: true)] ) private var items: FetchedResults var body: some View { VStack { ScrollView(.vertical, showsIndicators: false) { LazyVGrid(columns: columns, spacing: 40) { ForEach(
1
0
877
Jan ’25
NavigationSplitView detail view not updating
I have a NavigationSplitView with all three columns, and NavigationLinks in the sidebar to present different Lists for the content column. When a list item is selected in the content view, I want to present a view in the detail view. Since different detail views should be presented for different content views, I represent state like this (some details omitted for space): // Which detail view to show in the third column enum DetailViewKind: Equatable { case blank case localEnv(RegistryEntry) case package(SearchResult) } // Which link in the sidebar was tapped enum SidebarMenuItem: Int, Hashable, CaseIterable { case home case localEnvs case remoteEnvs case packageSearch } // Binds to a DetailViewKind, defines the activate SidebarMenuItem struct SidebarView: View { @State private var selectedMenuItem: SidebarMenuItem? @Binding var selectedDetailView: DetailViewKind var body: some View { VStack(alignment: .leading, spacing: 32) { SidebarHeaderView() Divider() // Creates the navigationLi
Topic: UI Frameworks SubTopic: SwiftUI
1
0
427
Jan ’25
LazyVGrid inside a List Crashes on iPhone 15 Pro Max (iOS 18.x) Simulator
We've seen an issue when using a LazyVGrid inside a List. The app crashes with: Thread 1: Fatal error: is stuck in a recursive layout loop When debugging the issue, we were able to narrow down the issue to a minimum reproducible example below: struct ContentView: View { let columns = [ GridItem(.adaptive(minimum: 43)) ] var body: some View { List { LazyVGrid(columns: columns) { ForEach(0..<15) { value in if value == 0 { Text(a) } else { Color.clear } } } } } } The issue can be reproduced on iPhone 15 Pro Max and iOS 18.x specifically. In a production app we have a similar layout, but instead of GridItem(.adaptive) we use GridItem(.flexible).
3
0
547
Jan ’25
[iOS 18.2 Beta] LazyVGrid within NavigationStack breaks animations
Hello. There seems to be a bug specifically in the iOS 18.2 (both Beta 1 and 2) and not seen in the previous versions. The bug is: when LazyVGrid is nested inside NavigationStack and some elements of the LazyVGrid have animations, navigating into any nested view and then going back to the initial view with the LazyVGrid causes all animations to stop working. Here is the example code inline: struct ContentView: View { @State private var count: Int = 0 var body: some View { NavigationStack { LazyVGrid( columns: Array( repeating: GridItem(spacing: 0), count: 1 ), alignment: .center, spacing: 0 ) { VStack { Text(String(count)) .font(.system(size: 100, weight: .black)) .contentTransition(.numericText()) .animation(.bouncy(duration: 1), value: count) Button(Increment) { count += 1 } NavigationLink(destination: { Text(Test) }, label: { Text(Navigate) }) } } } .padding() } } Once you run the application on iOS 18.2 Beta (I've tried on a real device only), the steps to reproduce are: Tap on the Increment butt
8
0
949
Dec ’24
Multi Section Sidebar using List with selections for macOS
I'm trying to implement a 3 column NavigationSplitView in SwiftUI on macOS - very similar to Apple's own NavigationCookbook sample app - with the slight addition of multiple sections in the sidebar similar to how the Apple Music App has multiple sections in the sidebar. Note: This was easily possible using the deprecated NavigationLink(tag, selection, destination) API The most obvious approach is to simply do something like: NavigationSplitView(sidebar: { List { Section(Section1) { List(section1, selection: $selectedItem1) { item in NavigationLink(item.label, value: item) } } Section(Section2) { List(section2, selection: $selectedItem2) { item in NavigationLink(item.label, value: item) } } } }, content: { Text(Content View) }, detail: { Text(Detail View) }) But unfortunately, this doesn't work - it doesn't seem to properly iterate over all of the items in each List(data, selection: $selected) or the view is strangely cropped - it only shows 1 item. However if the 1 item is selected, then the appropri
3
0
554
Jan ’25
VisionOS ARKit CameraFrame Sample Parameters Extrinsics
the following documentation tells me that the CameraFrame.Sample.Parameters.extrinsics is of type simd_float4x4, great! https://developer.apple.com/documentation/arkit/cameraframe/sample/parameters/4443449-extrinsics I have read in the answer of another post that this extrinsics represents the pose of the physical camera relative to the device anchor. Did I understand correctly that the device anchor is where the scene is rendered from onto the user's display? What is the coordinate system in which this offset is defined, which axis is left, which one is up, which one is forward? The last column of the extrinsics seems to define a translation of approximately 2 cm along the x axis, -2cm along the y axis and -5 cm along the z axis. I tried to measure the physical distance between the main left and right cameras in order to find out if it's rather 2cm or 5 cm from the middle, it looks more like 5, so I assume that the z axis is looking towards the right (from the user's perspective). Is that so? For x
4
0
796
Jan ’25
TestFlight takes long to send to Internal Testers
Normally uploading, processing and sending a TestFlight would take up to 30 minutes. But recently it slowed down to ~2 hours before the test app is actually send out to testers. Status updates from 'Processing' to 'Ready to Submit' still happens within 30 minutes, as usual. However nothing is send out to testers until 1-2 hours later. The 'Groups' column remains empty until the TestFlight is actually send. When trying to manually select a group the default 'Internal Group' is disabled. I guess because it knows it has to send to them and is busy trying to. Has anything changed in this process? And has anyone experienced the same or not? Useful either way.
5
0
6.4k
Sep ’23
Reply to cannot find in scope
So the complete code part1: struct ContentView: View { @State var text1: String = // <<-- Declare HERE ; could be an array of String @State private var tipa: [Double] = [] @State private var costa: [Double] = [] @State private var cost = @State private var costt: Double? = 0.0 @State private var paidt: Double? = 0.0 @State private var paid = @State private var tipp = @State private var tipc = @State private var tipaa = @State private var totalCost = @State private var totalTips = @State private var totalCash = @State private var tipcc = @State private var numbc = @State private var deletep = 0 @State private var number = 0 @State private var errorMsg = var body: some View { GeometryReader { g in NavigationStack { VStack { HStack { // No need to manually pad the date out with spaces, which will never be correct. // Just use an HStack and put a Spacer() in, so it goes: |<.....Spacer().....>Date| Spacer() Text(Date().formatted(date: .numeric, time: .omitted)) .foregroundStyle(Color.black)
Dec ’24
Reply to cannot find in scope
Okay, well, you went ahead anyway. Here's my update: // ContentView.swift import SwiftUI struct ContentView: View { @State private var tipa: [Double] = [] @State private var costa: [Double] = [] @State private var cost = @State private var costt: Double? = 0.0 @State private var paidt: Double? = 0.0 @State private var paid = @State private var tipp = @State private var tipc = @State private var tipaa = @State private var totalCost = @State private var totalTips = @State private var totalCash = @State private var tipcc = @State private var numbc = @State private var deletep = 0 @State private var number = 0 @State private var errorMsg = var body: some View { GeometryReader { g in NavigationStack { VStack { HStack { // No need to manually pad the date out with spaces, which will never be correct. // Just use an HStack and put a Spacer() in, so it goes: |<.....Spacer().....>Date| Spacer() Text(Date().formatted(date: .numeric, time: .omitted)) .foregroundStyle(Color.black) .fontWeight(.bold) .pad
Dec ’24