Search results for

column

2,078 results found

Post

Replies

Boosts

Views

Activity

Cannot create a SwiftUI Table with more than 10 columns, attempts to use Group do not work .... HELP
Trying to overcome the 10 columns limit of Table in SwiftUI, I am trying to use Group to split the number of Views by group of 10. This generate a compiler error: The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions Here is the code import SwiftUI //--------------------------------------------------------------------------------------------- struct TestStruct : Identifiable { var id = UUID () var name : String var val : Int } //--------------------------------------------------------------------------------------------- struct ContentView: View { @State var testData : [ TestStruct ] = [ TestStruct ( name: Leopold, val: 1 ), TestStruct ( name: Napoleon, val: 2 ) ] var body: some View { VStack { Table ( testData ) { Group { TableColumn ( Name ) { testStruct in Text ( testStruct.name ) } TableColumn ( Value ) { testStruct in Text ( String ( testStruct.val ) ) } } } } } } //---------------------------------------------------
0
0
1.8k
Sep ’22
Reply to controlTextDidEndEditing for View Based NSTableView
Yes, I usually set tags: func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { // … code cellView.textField!.tag = row + 256 * column. // If less than 256 rows ; otherwise cellView.textField!.tag = row + 256 * column This is a multiplexed value of row and col. I attach an IBAction to the tableViewCell: @IBAction func cellContentDidChange(_ sender: NSTextField) { // Let's find row and coll by demuxing the tag let rowIndiv = highWordTag % 256 let colVar = (sender.tag - rowIndiv) / 256 (that's Swift, but easily adaptable to objC)
Topic: UI Frameworks SubTopic: AppKit Tags:
Nov ’21
NavigationStack within NavigationSplitView's detail column clears the path when disappearing
I'd like to persist the path on a sidebar selection, so when user comes back to the sidebar selection, they land where they were before. Unexpectedly, the path gets cleared when sidebarSelection is changed from the NavigationStack that uses the path to something else. Is this an intended behavior? How to workaround it? Using TabView is one way, but TabView has its own problems, so I'm wondering if there's a solution within NavigationSplitView first. Here is a minimal reproduce of the issue: struct Home2: View { private enum SidebarSelection: CaseIterable, Identifiable { var id: Self { self } case files, tags } @State private var sidebarSelection: SidebarSelection? = .files @State private var path: [Int] = [] var body: some View { NavigationSplitView { List(SidebarSelection.allCases, selection: $sidebarSelection) { selection in switch selection { case .files: Label(Files, image: custom.square.stack) case .tags: Label(Tags, systemImage: grid) } } } detail: { switch sidebarSelection { case .files: NavigationStac
4
0
147
May ’25
Reply to give developer account to programmer?!
List the steps you take to sign in to your developer account. What you are seeing is what someone without a developer account would see if they signed in to Apple. When I sign in to my developer account, I see a Program Resources section with the following columns: App Store Connect, Certificates, IDs, and Profiles, and Additional Resources. Each of these columns has a list of links. Do you see these columns when you sign in? Are you able to click the Users and Access link I mentioned in Step 2 in my earlier answer? When I click the Users and Access link under App Store Connect, I see the following links at the top of the page: People, Sandbox, Keys, Shared Secret, and Xcode Cloud. The People link is the initially selected link. There is a Users sidebar with a list of categories. Selecting the All items shows all the users on my team with an Add button above the list of users. Clicking the Add button lets me add someone to my team. I am not an Apple employee so I cannot provide more
Topic: App & System Services SubTopic: General Tags:
Nov ’23
Reply to SwiftUI Inspector ideal width
In SwiftUI, the inspectorColumnWidth modifier is meant to control the width of an inspector column within a TableView. The ideal parameter of this modifier should set the initial width of the inspector column, and the system should remember the user-adjusted width for subsequent launches. However, in the beta version of SwiftUI you're using, it seems that the ideal width might not be respected on initial launch. Workarounds: While waiting for potential updates or bug fixes from Apple, here are a few workarounds you can consider to achieve your desired behavior: Set Minimum Width to Ideal Width: Since you want to guarantee the initial width while allowing users to reduce the width, you can set the minimum width to the same value as the ideal width. This way, users won't be able to resize the inspector column to a width smaller than the ideal width. This could be a suitable approach if you're okay with users having a fixed minimum width of 550. TableView() .inspector(isPresented: $sta
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’23
Reply to Modeling Tabular Data from Excel file in Swift
hi,if you're willing to turn the Excel file into tab-separated text, it is easy to read the data into whatever is your data model. assuming your spreadsheet has column titles along its top row, the code below will give you a dictionary for every data row in the spreadsheet, keyed by the column titlesvar theDatabase = YourDatabase() // whatever is your database model // read the file as one big string var fileContents:String do { fileContents = try String(contentsOfFile: destinationPath, encoding: String.Encoding.utf8) } catch let error { print(Error reading file: (error.localizedDescription)) fileContents = } guard fileContents.count>0 else { return theDatabase } // split out records (separated by returns) let records = fileContents.split { $0 == r } // first record is field names, i.e., column titles let fieldNames = findFields(String(records[0])) // all remaining records are data, so match each with field names of record 0 for k in 1..<records.count { let values = findField
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’19
Reply to "viewForTableColumn" vs "objectValueForTableColumn"
— All NSTableViews use NSTableColumn for their columns.— There are two ways of showing content in a table column:The old way uses subclasses of NSCell (like NSTextFieldCell), called a NSCell-based table view. The new way uses NSTableCellView, called a view-based table view. You should always use a view-based table view, and never the old way. (The old way is supported so that existing code doesn't stop working.)— In a view-based table view, you can still use objectValueForTableColumn, but you don't have to. Your table cells (NSTableCellView) has an objectValue property, that must be made to refer to an object that supplies data to the controls inside the table cell (buttons, text fields, etc). There are three ways of doing that:1. In your viewForTableColumn method, after you create the cell, you can simply set the property: NSTableCellView *cellView = [tableView makeViewWithIdentifier:tableColumn.identifier owner:self]; cellView.objectValue = …2. In your data source, you can implement objectValueForT
Topic: UI Frameworks SubTopic: AppKit Tags:
Feb ’18
Reply to Getting NSBrowser+NSTreeController to recognize its delegate
I slept on the problem and managed to find a workaround, although it's not a complete one.If I implement the delegate method -browser:numberOfRowsInColumn:, NSBrowser recognizes my object as an old-style delegate and will send all of the optional delegate methods. However, as I mentioned, this also severly limits the usability of NSBrowser because now calls to -itemAtRow:inColumn: and similar methods throw an exception that they are not supported.My solution (and by solution I mean hack) is to subclass NSBrowser and implement my own -itemAtRow:inColumn: method, like this:- (id)itemAtRow:(NSInteger)row inColumn:(NSInteger)column { NSMatrix* columnMatrix = [self matrixInColumn:column]; NSCell* cell = [columnMatrix cellAtRow:row column:0]; return cell.objectValue; }Since all of the cells in the NSMatrix are bound to the objects in the NSTreeController, the item of any given [row,column] is a well-known value. (Why NSBrowser can't do this is beyond me.)It doesn't solve the problem of -p
Topic: UI Frameworks SubTopic: AppKit Tags:
Jun ’15
Reply to Find which button is pressed in a Grid in SwiftUI
Oh I see. That's unfortunate but I can work around it by comparing the title property values. Thanks a ton for all your help. btw I changed the ObservableObjects to use generics. It doesn't seem to have an effect on functionality-wise. Everything works ok. However (this issue actually persisted before changing it to generics too), the SwiftUI preview for this view doesn't get rendered. swift class MenuViewObservableT: MenuItem: ObservableObject { var onButtonTap: ((MenuItem) - Void) = { _ in } } struct UserTypeMenuView: View { @ObservedObject var observable: MenuViewObservableMenu.UserType private let columns = [ GridItem(.flexible(), spacing: 20), GridItem(.flexible(), spacing: 20) ] var body: some View { ScrollView { LazyVGrid(columns: columns, spacing: 20) { ForEach(Menu.UserType.allCases, id: .self) { item in MenuButtonMenu.UserType(item: item, action: observable.onButtonTap) } } .padding(.horizontal) .padding([.top, .bottom], 20) } } } struct UserTypeMenuView_Previews: PreviewP
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’21
Reply to Instruments: what is static AppName.$main() [inlined]
I see I forgot to enable email notifications of replies... fixed. I'm using a Swift table with 4 columns. In testing I replaced the columns with a fixed Text view to see if that was an issue. It wasn't. There was in issue in row: closure to the table in that the array consisted of large-ish structs and a lot of time was being taken allocating and freeing memory to copy the array entries. I changed the struct to a class and saved about 40% of the delay time. Still, there is something going on. When I select an item in the table the user experience is 1) the row turns blue, 2) longish delay, 3) text in the first column changes color. Normally lots of other stuff goes on but I disabled all of it looking for the source of the longish delay. That delay is the hang reported above. If I show system libraries it looks like this: Note that I also scrolled the tracks to show View Body and the Core Animation Commits -- fwiw I am not doing any additional animation over whatever is built into Sw
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’23