Hi all, I'm working on a SwiftUI app (macOS only) that uses a Table to show contents of a directory. Each Table Cell seems to have a padding / gap which I would like to remove. If you look at the picture, I want the red rectangle to fill the whole cell. Does anybody know how to achieve this? Here's my current code for that column: TableColumn(name, value: .name) { item in HStack { if item.type == .directory { Image(systemName: folder) .frame(width: 14) } else { Text() .frame(width: 14) } Text(item.name) Spacer() } .contentShape(Rectangle()) .gesture(TapGesture(count: 2).onEnded { print(item) doubleClick(path: item.path) }).simultaneousGesture(TapGesture().onEnded { self.selectedFileItem = item.id }) .background(.red) .padding(.all, 0) } I want this to be applied to all columns in the table. I only showed one column as a reference. The table style is .tableStyle(.bordered(alternatesRowBackgrounds: true))
Search results for
column
2,078 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I am learning SQLite queries. I use prepare statement and one or more calls to a step statement. The prepare statement knows the pointer to the database, the UFT8 select statement and the name of the pointer which will point to the complied SQL select statement. The first step call runs the compiled select statement and if data is returned, the first row is made available via column calls. It seems logical to me that the select statement returns all matching rows but if the first step statement only has access to the first row of data, the balance of matching rows must be stored somewhere. Is this the case and if so where are the query results stored? Or is does this work in some other manner?
This is most definitely a bug, probably in TabularData itself. I boiled your example down to this: import Foundation import TabularData func test() { let csv = c CCCCCCCCCCCCCCCC var dataFrame = try! DataFrame( csvData: Data(csv.utf8), columns: [c], types: [c: .string] ) dataFrame.removeRow(at: 0) } test() and it crashes in roughly the same way. I’m running this as a command-line tool on macOS 13.4. I tested with both Xcode 14.3 and Xcode 15 beta and it crashes either way. I then put this code into tiny iOS test project and ran it on the iOS 17 beta simulator. It doesn’t crash there, suggesting that the bug has already been fixed. The really interesting thing is that removing a single character from CCCCCCCCCCCCCCCC makes the problem go away. Share and Enjoy Quinn “The Eskimo!” @ DTS @ Apple
Topic:
Programming Languages
SubTopic:
Swift
Tags:
I am working with data in Swift using the TabularData framework. I load data from a CSV file into a DataFrame, then copy the data into a second DataFrame, and finally remove a row from the second DataFrame. The problem arises when I try to remove a row from the second DataFrame, at which point I receive an EXC_BAD_ACCESS error. However, if I modify the timings column (the final column) before removing the row (even to an identical value), the code runs without errors. Interestingly, this issue only occurs when a row in the column of the CSV file contains more than 15 characters. This is the code I'm using: func loadCSV() { let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let url = documentsDirectory.appendingPathComponent(example.csv) var dataframe: DataFrame do { dataframe = try .init( contentsOfCSVFile: url, columns: [user, filename, syllable count, timings], types: [user: .string, filename: .string, syllable count: .i
Finally, in iPadOS 17 beta 5, I tested it and it worked! Thanks for resolving this bug that had been causing me frustration for the past 2 years. I now realize it was not my fault. I believe it's important to extend this fix to older versions of iPadOS as well since 3-column apps are completely unusable on those versions.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Certainly this iCloud upload being stuck bug is frustrating. My method to resolve it is as follows: Launch Activity Monitor, click on the CPU tab at the top, look for the bird process in the Process Name column, select it, and stop it (kill it) by clicking on the Stop icon on the tool bar (the one with an X inside a circle). You will noticed that the process id number listed in the PID column changes after a couple of seconds, which indicates that the bird process has been restarted by the system (The bird process is responsible of the iCloud background file synchronization). Most of the times this solution will work. If stopping the bird process did not solve the iCloud synching, then perform a full shutdown/restart of your computer. This is the ultimate fix that has always worked for me thus far.
Topic:
App & System Services
SubTopic:
Core OS
Tags:
I have a dataset with 3 columns item_id, user_id, rating. I created a coreML MLRecommender model from this dataset. I want to use this model to get the top 10 predictions for a new user (not in the original dataset) but who has rated a subset of the items in the dataset. I don't see any API in the Apple docs to do this. Both the recommendations APIs only seem to accept an existing user-id and get recommendations for that user. The WWDC tutorial talks about a prediction API to achieve this. But I dont see this in the Apple API documentation and code below from WWDC tutorial cannot be used since it does not give details on how to create the HikingRouteRecommenderInput class it passes into the prediction API. let hikes : [String : Double] = [Granite Peak : 5, Wildflower Meadows : 4] let input = HikingRouteRecommenderInput(items: hikes, k: 5) // Get results as sequence of recommended items let results = try model.prediction(input: input) Any pointers on how to get predictions for new user would be greatl
The issue I am encountering is, I need to be able to create a view in SwiftUI that looks like a sentence of text but has blanks where the user can enter their own text. I also need a way to be able to capture the entered text from the binding, but not sure how to do multiple bindings in a loop. Ive tried a few options and the closest I have got is using LazyGrid, but it doesn't look like a normal sentence due to spacing? Any help appreciated. struct MultiText: View { @State var text = There was once a {-} that only had {-} in it. How did they get in? {-} @State var answerText: String = XXXXXXX let rows = [ GridItem(.adaptive(minimum: 80)) ] var body: some View { GeometryReader { geo in HStack { LazyVGrid(columns: rows, alignment: .leading, spacing: 0) { ForEach(text.components(separatedBy: ), id: .self) { component in if component == {-} { TextField(, text: $answerText ) } else { Text(component) } } }.frame(width: geo.size.width * 0.80) Image(systemName: flag).frame(width: 30, height: 30) }.frame(wi
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:
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
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
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:
Is there a way to print a simple report of the tests? We want a list of tests, with a report of ‘pass’ or ‘fail’ for each one. We need this for the V&V process for our app. We found what we want in the ‘Report Navigator’ (the option on the far right in the left hand column on Xcode) by clicking on ‘Test’. However, this isn’t printable. Below ‘Test’ is ‘Build’, ‘Coverage’, and ‘Log’, which can be exported, but all of them show more information that we wanted. (Photo for reference) Is there a way to print out that page when you click on ‘Test’? What am I missing here?
I'm creating a horizontal scroll view through the collection view. I used flowlayout for layout, and I set the scroll direction to horizontal. I found a bug in this situation. If the width of the item is different, line spacing is not applied, but item spacing is applied. Since it is a horizontal scroll, line spacing should be applied in the direction of the column, but item spacing is applied. Does anyone know anything about this? // // ViewController.swift // minimumLineSpacingTest // // Created by Hoonki chae on 2023/07/12. // import UIKit class TestCell: UICollectionViewCell { } class ViewController: UIViewController { let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) override func viewDidLoad() { super.viewDidLoad() self.view.backgroundColor = .white self.collectionView.frame = .init(origin: .init(x: 0, y: 100), size: .init(width: self.view.frame.width, height: 50)) self.view.addSubview(self.collectionView) self.collectionView.backgroundColor
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: