I want to let voice over read row header, row column, I could implement it by UIAccessibilityContainerDataTableCell in UIKit, but I didn't find any equivalent in SwiftUI. Is there any other way I can work around this?
Search results for
column
2,071 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
You can definitely use Grid for this! You can do something like this: Grid{ GridRow { ForEach(0..<3) { _ in Text(header) .padding() } } ForEach(0..<3){ num in GridRow { Text((num)) .padding() ForEach(0..<2) { _ in Text(X) .padding() } } } } The first GridRow would iterate through your data for your headers. Here, I have 3 headers as I will only be using 3 columns for my data. Then, I have a ForEach that gives me 3 more GridRows. Each of these contain the label for the vertical axis label and then another ForEach that contains the data for that row. This gives you both vertical and horizontal axis labels and the data is laid out by row.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
I've run into two issues using NavigationSplitView with .navigationDestination modifiers. First, programmatic navigation using .navigationDestination(isPresented: destination) does not seem to work when used in the content column of a NavigationSplitView It does, however, work from the sidebar / first column. Second, it appears that we need to add redundant .navigationDestination modifiers on iPhone and iPad to handle how NavigationSplitView is adapted when used on iPhone. Specially, when it is collapsed into a NavigationStack. Also, when an iPad UI is collapsed to a NavigationStack via Stage Manager, then expanded again, .navigationDestination modifiers in the content column seem to get lost, preventing the content list from working going forward. This somewhat explains why dynamically adding .navigationDestinations via the first column push isn't sufficient. However it results in a broken UI. Is there one location we can place .navigationDestination modifiers to work both
Hello, I’d like to display items in a grid, with both a header row and a header column. Something like this : A B C D 1 x y x x 2 x x x x 3 x y y y 4 y x x y What elements should I use for this arrangement? It seems Grid doesn’t allow for headers that would behave differently than the data cells, and, if using a separate HStack or VStack for the headers, I’m not sure how I could force data lines and rows to stay aligned with the headers.
It's been a few months since I started Swift. Referring to the SWIFT website I wrote the code as follows. let layout2: [GridItem] = Array(repeating: .init(.flexible(minimum: 40, maximum: 75)), count: 5) let layout = [GridItem(.fixed(75)),GridItem(.fixed(75)),GridItem(.fixed(75)),GridItem(.fixed(75)),GridItem(.fixed(75))] let layout3: [GridItem] = [GridItem(.adaptive(minimum: 70), spacing: 5)] struct ContentView: View { @State var scores: [Int] = [1,3,4,3,2, 2,3,3,4,3] var body: some View { // Text((scores.count)) = 10 // ScrollView { HStack { LazyVGrid(columns: layout, spacing: 1) { ForEach(scores, id: .self) { num in ZStack { Rectangle() .foregroundColor(.accentColor) .frame(height: 45) Text((num)) .foregroundColor(.red) } // ZStack } // ForeEach } // LazyVGrid } // HStack // } // ScrollView } // body } // ContentView struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }language code-block The result was different from what I thought and was as follows. Th
I'm using a NavigationSplitView with two columns for a macOS app. The sidebar column shows a list of items and the right pane shows the details for the selected item. I'm using NavigationLink to create clickable sidebar items and pass my own View-type struct that displays the row information. When I decided to add a slight background color to the rows & slight hover state, I noticed that the row view container is smaller than the NavigationLink when selected (I made the colors brighter to emphasize the issue - rows have a gray background & brighter gray hover state and blue is the built-in styling provided by NavigationLink). My code for the NavigationSplitView which lives in the body of the main ContentView: NavigationSplitView(columnVisibility: $columnVisibility) { VStack{ if userSettings.cases.isEmpty { Text(Press + to add your first case) .font(.title2) .foregroundColor(.gray) .multilineTextAlignment(.center) } else { List(userSettings.cases, selection: self.$selectedCase) { case
I want to make it like this How to disable the button that open the side bar, I only need the content and the detail view. I don't need the sidebar view. Below is my code import SwiftUI @available(iOS 16.0, *) struct Screen: View { @ObservedObject var userData = UserData() @State private var isIntroShown = true @State var Itema: Bool = false @State private var showFoodDetail = false @State var rb: Bool = false @State var Setting: Bool = false @State var Recipe: Bool = false @Environment(.defaultMinListRowHeight) var minRowHeight @Environment(.colorScheme) var colorScheme @State private var searchText = private let adaptiveColumns = [ GridItem(.adaptive(minimum: 170)) ] var columns = Array(repeating: GridItem(.flexible(), spacing: 10), count: 2) var filteredRooms: [Room] { if searchText.isEmpty { return userData.rooms } else { return userData.rooms.filter { room in let foodNames = room.food.map { $0.name.lowercased() } return room.name.lowercased().contains(searchText.lowercased()) || foodNames.conta
You're pushing multiple stacks that share the same path. So one stack is trying to push another stack which is trying to push the other stack.... It's a happy coincidence that ObservableObject doesn't infinite loop, I'm surprised it does not. 2 general rules will help when using the navigation system: move navigationDestination modifiers as high up in the view hierarchy. This is more efficient for the Navigation system to read up front than with potentially every view update. Don't push stacks onto stacks, and try to avoid entire NavigationStacks coming and going from the columns of a NavigationSplitView. NSV will adopt the stack and integrate its state with the state of the whole split view. I ran this example on macOS and it looked as expected import SwiftUI import OSLog final class NavigationModel: ObservableObject { @Published var path = NavigationPath() { didSet { print(navigationModel.path.count: (path.count)) } } } struct Report: Hashable { var title: String = Report Title } private let logger
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Finally I went with something similar to what you suggested : var body: some View { GeometryReader {geometry in let size = min(geometry.size.width, geometry.size.height) let tileSize = size / 8 VStack( spacing: 0.0) { ForEach((0..<8).reversed(), id: .self) { rowIndex in HStack(spacing: 0) { ForEach((0..<8), id: .self) { columnIndex in TileView(x: rowIndex, y: columnIndex) } } } }.overlay(alignment: .bottomLeading){ ForEach(Array(model.initialState.keys), id:.self) { let (row, column) = $0.tuple() let piece = model.initialState[$0]! let offset = model.offset(piece: piece, val: tileSize) PieceView(type: piece.figure, side: piece.side) .frame(width: tileSize, height: tileSize) .offset(x: CGFloat(row) * tileSize, y: -CGFloat(column) * tileSize) .offset(offset) } } } } I thought Z Indexes are global ... then what they refer to ?
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
actually what you need to do is remove the y component and not the z component, if you want to convert from 3D->2D, from CapturedRoom you get dimensions.x (wall length) and (transform) .columns.3.x, transform .columns.3.z) is the coordinate of the center of the wall and the direction(transform.columns.0.z, transform.columns.0.z), is the direction of the wall, now you there is a starting and ending point of a wall, similar to other things
Topic:
Spatial Computing
SubTopic:
ARKit
Tags:
launchdata.json: [ { name: Smartcard, imageName: Smartcard, description: A all new way to buy and sell stuff featuring RFID and NFC for touchless transactions and with local server you can pay with your phone., department: Ticki Finance, productid: 1737484, id: 1, creator: The Ticki Team }, { name: Ink pad, imageName: Inkpad, description: A quick and easy way to take fingerprints and stamp stamps:), And with a quick water activation taking only 15 seconds you can setup in no time. Also, refilling the ink chamber is super easy, all you have to do is put ink in the middle hole., department: Ticki Design, productid: 7338388, id: 2, creator: The Ticki Team }, { name: Wallet, imageName: Wallet, description: Ever had issues with your credit cards falling out of your pocket/wallet? Well this fixes any issues. Introducing Ticki Wallet. , department: Ticki Finance, productid: 2444495, id: 3, creator: The Ticki Team }, { name: Pencil Case, imageName: PencilCase, description: I always lose my my pencils. How about you?
I have a simple problem, but I’m not able to solve it in an easy way, so I suspect I’m doing something wrong. I have a simple view-based NSTableView, which is a dragging source. The data being dragged are provided to the pasteboard using the standard data source method - [NSObject tableView:writeRowsWithIndexes:toPasteboard:]. When rows of the table view are dragged, AppKit automatically creates a dragging image consisting of the visual copy for all dragged rows and all columns of the table view. If I want only particular columns, I can override -[NSTableView dragImageForRowsWithIndexes:tableColumns:event:offset:] and include only the columns I want in the dragged image. Since -[NSObject tableView:writeRowsWithIndexes:toPasteboard:]is rendered deprecated as of macOS 11, I want to use the alternative (which also supports multiple item dragging) -[NSObject tableView:pasteboardWriterForRow:]. However, when I use this method, AppKit creates a dragging image consisting of the visual copy
Same issue is happening when you have Three Column layout. But it seems to be more visible what is happening. When I select other category in the main sidebar, the selected item in secondary sidebar won't get unselected, plus new item from selected category gets selected. So now after two clicks I have somehow two selected items in my secondary sidebar and when i'll continue playing with it I'll get thread ERROR. The problem is the automatic selection of item in second list. you can't touch on that and reset it when the category from primary sidebar is changed. What is really surprising for me is that I haven't found any threads about this so far, even though this behavior is happening in the most basic example of three column layout where you have same items in different categories.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
I find a glitch of CGContextSetFillPattern glitch only on Ventura. If the size of the pattern is a multiple of 4, there will be a hole in the upper right corner of the pattern in the first column. I make a demo Xcode project here. I have tried all three CGPatternTiling enum values, all have the same result.
I'm trying to get results from a SQLite database, containing rows and columns, into a NSTableView, using Swift. There is no problem with the database query and I'm getting no errors when running the application. However, when displaying data, I always get the same (last) row in the table - repeated so many times as the total number of rows. What is missing in my code ? Thanks in advance. `class SecondViewController: NSViewController, NSTableViewDataSource, NSTableViewDelegate { @IBOutlet var tableview: NSTableView! var querySQL = var bdadosDB: OpaquePointer? var statement: OpaquePointer? var allRows = [String]() var rows = [String]() var cols = [String]() var CellIdentifiers :[String] = [ordCell, procCell, espCell, natCell, recCell, estCell, julgCell, decCell] override func viewDidLoad() { let dirPaths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) let docsDir = dirPaths[0] let databasePath = (docsDir as NSString).appendingPathComponent(bdados.db) let dbpath = datab