Search results for

column

2,052 results found

Post

Replies

Boosts

Views

Activity

Swift UI Table - Problems removing selection from row
Hi,i have been trying out SwiftUI Table and wanted to present a details view when click on Table Row occurs, but I couldn't figure out how to deselect row once its been selected, while it may not be what Table was intended for, but I still think this code should be valid. (iPadOS) struct Person: Identifiable { let givenName: String let familyName: String let emailAddress: String let id = UUID() } private var people = [ Person(givenName: Juan, familyName: Chavez, emailAddress: juanchavez@icloud.com), Person(givenName: Mei, familyName: Chen, emailAddress: meichen@icloud.com), Person(givenName: Tom, familyName: Clark, emailAddress: tomclark@icloud.com), Person(givenName: Gita, familyName: Kumar, emailAddress: gitakumar@icloud.com) ] @State private var selectedPeople: Person.ID? @State private var detailsViewPresented: Bool = false var body: some View { Table(people, selection: $selectedPeople) { TableColumn(Given Name, value: .givenName) TableColumn(Family Name, value: .familyName) TableColumn(E-Mail Address, va
1
0
1.6k
Jul ’23
Help customizing the accessibility of a large UICollectionView
Hello, I am turning to this forum because I suspect I am doing it wrong when it comes to implementing VoiceOver accessibility in my collection view. I suspect this because the system has resisted everything I have tried to do, fought it tooth and nail, and I can't see any way to get this to work. The Collection View I have a collection view that displays a large dataset. It uses a custom collection view layout to create a spreadsheet-like view. It has hundreds of rows, and each row can have hundreds of items. The items in each row do not conform to specific column widths. Their width is defined by the data they display, and for the purposes of this discussion, can be considered to be arbitrary. To the left of the table is a column of sticky headers whose position remains fixed in relation to the content. On top of the table is a row of headers, whose position also remains fixed. The Problem The default accessibility behavior that Apple has baked into UICollectionView is completely impractica
2
0
2.3k
Jul ’23
Reply to SQLite - Testing for existence of a table
It is my understanding that the SELECT statement returns a 0 if the table does not exist and 1 if it does. Actually that statement will return a result row if the table exists, and no result rows if it doesn’t exist. If you really want a result row containing a number every time, then you could use: SELECT COUNT(*) FROM sqlite_master WHERE type = 'table' AND name = 'Contact' But this would require you to fetch the column value to check the number. Your original query actually makes this task easier by letting you simply check if a row was returned or not. the API step statement returns 101 (SQLITE_Done) if the table does not exist. That means sqlite3_step has finished stepping through all the result rows, of which there are none. But if the table does exist it does not return 101. That would be SQLITE_ROW which means it got a result row. If you were to call sqlite3_step once again (or in a loop) you would get SQLITE_DONE the next time.
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’23
SwiftUI/Table/Sort: Problem with the sort function on a Table
Hello everyone. I'm having a problem using the table sort function in Swiftui. Here's an example to illustrate (data is provided by an API that returns fake data) : struct CompanyListResponse: Codable { let status: String let code: Int let total: Int let data: [CompanyData] } struct CompanyData: Codable, Identifiable { let id: Int let name: String let email: String } @Observable final class ViewModel { var companies : [CompanyData] = [] func fetch() async { guard let url = URL(string: https://fakerapi.it/api/v1/companies?_quantity=200) else { return } do { let (data, _) = try await URLSession.shared.data(from: url) let decoder = JSONDecoder() let response = try decoder.decode(CompanyListResponse.self, from: data) self.companies = response.data } catch { print(Error fetching data: (error)) } } } struct ContentView: View { @State private var viewModel = ViewModel() @State private var sortOrder : [KeyPathComparator] = [.init(.name, order: SortOrder.forward)] var body: some View { Table(of: CompanyData.self, sort
1
0
929
Jul ’23
Reply to How to capture unknown number of matches using RegexBuilder?
Just want to clarify, suppose I want to parse a table with multiple columns each separated by “|”, I can do one of the followings and use firstMatch(of: regex) or wholeMatch(of: regex), but they assume fixed number of columns in the table. How do I deal with dynamic number of columns? // using multi-line literal let regex = #/ (|) (? (.*?)(?=|)) (|) (? (.*?)(?=|)) (|) (? (.*?)(?=|)) /# // using RegexBuilder let separator = /|/ let regexBuilder = Regex { separator Capture ( OneOrMore(.any, .reluctant) ) separator Capture ( OneOrMore(.any, .reluctant) ) separator Capture ( OneOrMore(.any, .reluctant) ) separator }
Topic: App & System Services SubTopic: General Tags:
Jul ’23
Display a LazyVGrid with Sections
I am trying to render a list of entities that are split into sections (think CoreData NSFetchedResultsSectionInfo). This my solution, however it renders poorly. The ScrollView is far too long, scrolling is not fluid and may freeze. struct SectionsGridView: View { let results: Sections let columns = [ GridItem(.adaptive(minimum: .cellSize)) ] var body: some View { ScrollView { LazyVGrid(columns: columns, spacing: .gridSpacing, pinnedViews: .sectionHeaders) { ForEach(results) { section in Section(header: Text(section.title?.uppercased() ?? error)) { ForEach(section) { item in GridCell().environmentObject(item) } } } } } } } private extension CGFloat { static let gridSpacing = 8.0 static let cellSize = 100.0 } I believe this solution (or very similar) used to be in the documentation. I have tried several ways of doing this, either I get the scrolling issue or pinnedViews won't pin.
1
0
2.6k
Jul ’23
Reply to Reset Matrix Help
for anyone who might have the same question/problem. here's the sample that works as I wanted. import SwiftUI struct ContentView: View { let numberOfRows = 5 let numberOfColumns = 5 @State var matrix: [[Int]] = Array(repeating: Array(repeating: 0, count: 5), count: 5) @State var selectedRow1 = 0 @State var selectedColumn1 = 0 @State var selectedRow2 = 0 @State var selectedColumn2 = 0 @State var selectedRow3 = 0 var body: some View { VStack { Image(systemName: globe) .imageScale(.large) .foregroundColor(.accentColor) Text(Hello, world!) Form { Section(header: Text(Question 1)) { Picker(Select a row:, selection: $selectedRow1) { ForEach(1...numberOfRows, id: .self) { row in Text((row)) } } .pickerStyle(SegmentedPickerStyle()) Picker(Select a column:, selection: $selectedColumn1) { ForEach(1...numberOfColumns, id: .self) { column in Text((column)) } } .pickerStyle(SegmentedPickerStyle()) } Section(header: Text(Question 2)) { Picker(Select a row:, selection: $selectedRow2) { ForEach(1..
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’23
Reset Matrix Help
Hi there! can someone help me with this one: func resetMatrix() { matrix = Array(repeating: Array(repeating: 0, count: numberOfColumns), count: numberOfRows) let coordinates = [ (selectedRow1, selectedColumn1), (selectedRow2, selectedColumn2), (selectedRow3, selectedColumn3) ] for (row, column) in coordinates { matrix[row - 1][column - 1] += 1 } } i can't seem to make it work. i want it to work like this: If the chosen coordinate in Question 1 is (2,2), it will place the value 1 in the matrix coordinate (2,2). If the chosen coordinate in Question 2 is also (2,2), it will increment the value in the matrix coordinate (2,2) by 1, making it 2. Similarly, if the chosen coordinate in Question 3 is (2,2), it will increment the value in the matrix coordinate (2,2) by 1 again, making it 3. Thank you!
1
0
413
Jul ’23
Reply to Creating a dynamic 5X5 Matrix
import SwiftUI import UIKit class MatrixViewController: UIViewController { let matrix = [ [A5, B5, C5, D5, E5], [A4, B4, C4, D4, E4], [A3, B3, C3, D3, E3], [A2, B2, C2, D2, E2], [A1, B1, C1, D1, E1], ] let matrixLabelSize: CGFloat = 30.0 override func viewDidLoad() { super.viewDidLoad() setupMatrixView() } func setupMatrixView() { let matrixView = UIView() matrixView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(matrixView) let matrixViewWidth = CGFloat(matrix[0].count) * matrixLabelSize let matrixViewHeight = CGFloat(matrix.count) * matrixLabelSize NSLayoutConstraint.activate([ matrixView.centerXAnchor.constraint(equalTo: view.centerXAnchor), matrixView.centerYAnchor.constraint(equalTo: view.centerYAnchor), matrixView.widthAnchor.constraint(equalToConstant: matrixViewWidth), matrixView.heightAnchor.constraint(equalToConstant: matrixViewHeight) ]) var positionCounts: [String: Int] = [:] //counting the number of occurences - - - - - - this part for coordinate in coordinates { let row = coor
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’23
Reply to Creating a dynamic 5X5 Matrix
From what I've understood, it doesn't need to be 5 dimensional, but rather, 2 dimensional. The dimension in a matrix doesn't correspond to the number of rows and columns. In your case, two dimensions seems enough: one for the severity (from one to five), and one for the likelihood (1 to 5). You could therefore store data like so : Matrix[2][5] = 3 (which would mean that there are 3 questions that have a severity of 2 and a likelihood of 3). A good visual representation of the dimensions of a matrix would be the following. A one-dimensional matrix is just an array/list. A two dimensional array corresponds to an Excel/Numbers spreadsheet. And a three dimensional array could be use to store the coordinates of the cubes composing a Rubik's Cube, for example. Above 3, it's hard to have a visual representation. A 5-dimensional matrix would be suitable if you had 5 different sliders per question. Therefore, if you can represent your table in a spreadsheet, it means that two dimensions is enough. Let me know
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’23
Issue inserting row in TabularData's DataFrame
I'm fairly new to Swift programming so I might be overlooking something, but I'm puzzled why the following code doesn't properly insert a row in a DataFrame. The goal is to move a row at a given index to a new index. I would normally: Copy the row that I want to move Remove the row from the original dataset Insert the copy to the new position The CSV I'm using is from Wikipedia: Year,Make,Model,Description,Price 1997,Ford,E350,ac, abs, moon,3000.00 1999,Chevy,Venture Extended Edition,,4900.00 1999,Chevy,Venture Extended Edition, Very Large,,5000.00 1996,Jeep,Grand Cherokee,MUST SELL! air, moon roof, loaded,4799.00 My code (Swift playground): import Foundation import TabularData let fileUrl = Bundle.main.url(forResource: data, withExtension: csv) let options = CSVReadingOptions(hasHeaderRow: true, delimiter: ,) var dataFrame = try! DataFrame(contentsOfCSVFile: fileUrl!, options: options) print(Original data) print(dataFrame) let rowToMove: Int = 2 let row = dataFrame.rows[rowToMove] print(Row to move) print(ro
4
0
1k
Jul ’23
Reply to Build Simulator crash
The code is very long so i hope this edit is sufficient to read. Where do you use relativeRiskPickerIndex31? - there are 31 questions in this part of the app,. each app has 2 sets of answers for users to choose from. #1 Slope Angle (they choose answer from picker one) and picker two in the relativeRiskPickerIndex.. basically there are from 1 until 31 risk picker indexes using this: let relativeRiskChoices = [Select, Negligible, Minor, Moderate, Significant, Major] let relativeRiskScores = [-,A, B, C, D, E] //the code above this line is from another swift file that just gets called to the file to the code below. The state var values are all zero. There is no error message inside the code lines but when I run the simulator and try to run and pick answers from the questions and answers inside the simulator, it Freezes and stops working. so i have to force quit it again to try to run it again. however, if i do not use the pickers and just directly try to export pdf, it works. The last time I tried this popped up
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’23
VFS deadlock (WebDAV on Apple Silicon only)
FB9108925 FB10408005 Since Apple Silicon we've seen a lot of WebDAV instability in macOS 11.x, 12.x and now 13.x that isn't found on x86 Macs. Some were fixed in earlier minor OS upgrades (e.g. webdavfs-387.100.1 that added a missing mutex init), but it's still highly unreliable. The purpose of this post is to put more focus on the bug, see if there is something else we can do to help solve this, as well as hear about potential workarounds from other people experiencing the same problems. I've got a reproducible case described below that triggers a deadlock in VFS every time, requiring a hard reboot to fully recover. Before reboot I've captured this stack trace showing the WebDAV/VFS/UBC/VM layers getting tangled up (macOS 13.2 Build 22D49 running on Macmini9,1): Thread 0x16358 1001 samples (1-1001) priority 46 (base 31) 1001 thread_start + 8 (libsystem_pthread.dylib + 7724) [0x18d2e0e2c] 1001 _pthread_start + 148 (libsystem_pthread.dylib + 28780) [0x18d2e606c] 1001 ??? (diskarbitrationd + 99400) [0x100d5c448
1
0
1.1k
Jul ’23
FileManager Has Saved My Images - yet I cannot see / display them whenever I close and reopen the application.
So basically I can tell that the images are being saved by the system (it shows it on the debug terminal) however whenever I close, and then reopen the app the images firstly aren't there at all but also whenever I search the address name I saved them as... I have tried diagonsing the problem by changing UUID's, changing PNGs to JPGS - no matter what I do it does not show once the application has closed. I think it might have to do with how the image are .HEIF (apple's standard) but I don't have any concrete evidence to back this up. If anyone can help it would be greatly apperciated. import SwiftUI import MapKit import CoreLocation struct ContentView: View { @StateObject private var mapAPI = MapAPI() @State private var text = @State private var locationInfo: String = @State private var showLocationInfo = false @State private var imageUrls = [String]() // Array to store image URLs @State private var showImagePicker = false @State private var showCamera = false @State private var selectedImage: UIImage? @Sta
2
0
601
Jul ’23
How do I disable a button while it has focus
I have a view that shows a table and 4 buttons. Each button allows the user to step forward and backwards through the data. Buttons are enabled and disabled based on where you are in the data. If you are less than 200 values to the end of the data for example, the Page Down - 200 button is disabled. Everything works fine if the mouse is used to run the code associated with each button. But in this case I think the buttons never get focus. Focus I think remains with the sidebar content item that brought up the table view (am using a navigation split view). If I tab over to the page down 200 button and use the space bar to run its associated code I get the error AttributeGraph: cycle detected through attribute 864480. I think the problem lies with attempting to disable the button while it has focus but am not 100% sure. I have tried to change the focus prior to disabling the button but I get the same error. I think there is some fundamental that I am missing. Below is my table view along with the page down 200
3
0
1.6k
Jun ’23