Search results for

column

2,047 results found

Post

Replies

Boosts

Views

Activity

Reply to Populate one column based on values of other column in a NSTableView
Here is how I would do: You have a dataSource for the table, which is a 2 dimensional array. Right ? array[column][row] Then the second column array[1] should be computed based on the values of first column array[0] So, when you change an item in column 0, recompute column 1 and ask for reloading with func reloadData(forRowIndexes rowIndexes: IndexSet, columnIndexes: IndexSet)
Topic: UI Frameworks SubTopic: AppKit Tags:
Mar ’21
NavigationSplitView content column renders list in plain style – even on iPhone
Hi everyone, I’m building an iOS app that originally targeted iPhone using NavigationStack. Now I’m adapting it for iPad and switched to using NavigationSplitView to support a three-column layout. The structure looks like this: NavigationSplitView { A // Sidebar } content: { B // Middle column – this shows a list } detail: { C // Detail view } The issue is with the list shown in view B (the content column). It appears completely unstyled, as if it’s using .listStyle(.plain) — with no background material, and a very flat look. I can understand that this might be intentional on iPad to visually distinguish the three columns. However, the problem is that this same unstyled list also appears on iPhone, even though iPhone only shows a single column view at a time! I tried explicitly setting .listStyle(.insetGrouped) or .listStyle(.grouped) on the list in view B, but it makes no difference. When I go back to NavigationStack, the list in B is styled properly, just as expe
0
0
57
Aug ’25
Reply to UILabels of three UIPickerViews revert to previous value (sometimes) and change without selection.
Thanks Claude for taking a look. This is the grid table with the pickers in the top row. The user should be able to pick a different gender (eg, Masculine, Neutral or Feminine) for each column, and the values below, in that column, should update (of course, the picker should also show the selected value - which is the problem).| Masculine | | Masculine | Masculine |-- -- -- -- -- -- --- -- -- -- -- --- -- - -- --- - - -- -| Der Mann | gibt | dem Hund | den Ball. |additional rows of examplesThe UILabels that behave strangely are the 3 picker labels in the top row.The cases, 4...28, are for the attributed text (put together in a separate method). The rest of the cellForItem, is simply: case 1: cell.label.text = nil case 4...32: cell = cVCellContents(cell: cell, indexPath: indexPath, offset: 0) default: cell.label.attributedText = NSAttributedString(string: No case) } return cell }To demo what I mean about the picker labels, if I roll the column 1 picker to 'Neutral', the data for the
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’19
Reply to Make method less repetative
This is the best I can come up with:private func generateLoserLocationFunction(numberOfPlayers: Int) -> (column: Int, row: Int) -> (column: Int, row: Int) { let closure : (column: Int, row: Int) -> (Int) if numberOfPlayers == 8 { closure = { row, column in switch column { case 0: return row / 2 case 1: return row ^ 1 default: return 0 } } } else if numberOfPlayers == 16 { closure = { row, column in switch column { case 0: return row / 2 case 1: return 3 - row case 2: return row ^ 1 default: return 0 } } } else if numberOfPlayers == 32 { closure = { row, column in switch column { case 0: return row / 2 case 1: return (row + 4) % 8 case 2: return row case 3: return row ^ 1 default: return 0 } } } else { abort() } return { row, column in let newCol = -2 * column return (newCol, closure(column: row, row: column)) } }
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’15
Reply to NavigationSplitView Collapse Button
Hi @Ammar S. Mittori, The way that mail works on my iPad is that it shows two columns at first, and when you press the button to expand to three columns, that button disappears. To go back to the two column view, you click on the rightmost detail column and it will collapse. If you do want to show a button to collapse the third column, you can try code like this: struct ContentView: View { @State private var columnVisibility: NavigationSplitViewVisibility = .all var body: some View { NavigationSplitView(columnVisibility: $columnVisibility) { Text(Column 1) } content: { Text(Column 2) .toolbar { Group { if columnVisibility == .all { ToolbarItem(placement: .navigation) { Button(Back){ columnVisibility = .doubleColumn } } } } } } detail: { Text(Column 3) } } } This code sets a variable for the column visibility to be all the columns, and then changes that variable to just two columns when the back button is clicked
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’23
Growing entries to natural width of column in SwiftUI Grid
The new Grid View looks like it brings us a simple way to get row-column layouts into our SwiftUI apps! I wonder if someone can help me with one aspect: I have a situation similar to the one described for the Pet Leaderboard App in the Compose custom layouts with SwiftUI video. But I want to save space by putting the Cat/Goldfish/Dog voting buttons in the leaderboard table itself, in the first column, instead of the labels. Here's the code for a simplified version of that table: import SwiftUI struct TableDemo: View { var body: some View { Grid(alignment: .leading) { GridRow { Button { // vote for Cat } label: { Text(Cat).fontWeight(.bold).foregroundColor(.white).padding().background(.green).cornerRadius(8) } Text(23).fontWeight(.bold).foregroundColor(.white).gridColumnAlignment(.trailing) } GridRow { Button { // vote for Goldfish } label: { Text(Goldfish).fontWeight(.bold).foregroundColor(.white).padding().background(.green).cornerRadius(8) } Text(3).fontWeight(.bold).foregroundColor(.white
0
0
717
Oct ’22
Reply to .navigationViewStyle(.columns) doesn't work
Can you clarify what you mean by fixed Navigation View? Anyway, you may need to define at least two columns inside NavigationView to test how .columns work. A simple example: struct CollectionView: View { var body: some View { if #available(iOS 15.0, *) { NavigationView { //First column VStack { NavigationLink(destination: //Second column replacement Text(Hello) .navigationBarTitle(Hello) ) { Text(To hello) } } .navigationBarTitle(List, displayMode: .large) //Second column EmptyView() } .navigationViewStyle(.columns) } else { // Fallback on earlier versions } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to How SwiftUI Table sorting works ?
Hi himav, for the follow up questions you had, clicking on the Family name column header would change the sortOrder array property to include the Comparator for that column (or reverse that Comparator if the sortOrder array already had one for that column). You could see the sortOrder binding as a representation of how different columns want to take part in sorting - and then you could sort the data accordingly. For custom Comparator on individual columns, you could use one of TableColumn's initializers that come with comparator as a parameter, and that custom comparator you provided will be included into sortOrder if you click on the corresponding column header. Hope this helps!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’23
Reply to How to set different heights for rows of same UIPickerView?
It's unclear what you mean by One of the rows is of just plain string text. The other row of png images.A picker has different columns and each column has many rows. The column is called a component and is numbered from 0 to a few (like 2 or 5). There can be many rows. In your code, if wordPicker was 0 or 1 it would make sense - that would be the column, or component, that had the words in it. Each row in that column would have a height of 60. And each row in the other columns would have a height of 200.I suspect that wordPicker is not an NSInteger less than the number of columns (aka components) in the picker. The number of columns is set by your response to:- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{ return 2;}
Topic: UI Frameworks SubTopic: UIKit Tags:
Aug ’16
With Swift, can Cocoa Bindings be used to sort by a column in NSTableView?
I'm building a Swift app, and can successfully populate the rows of an NSTableView using Cocoa bindings in a Storyboard. When I hook up a NSTableColumn's Sort Key & Selector, the click-on-column-heading becomes active (the sort-direction icons appear as expected), but the rows are not re-sorted. I've thrashed around a bit, replacing my Swift Array with an NSMutableArray, trying variations on Sort Key, but no joy... Anyone have any clues?
4
0
1.8k
Feb ’18