Search results for

column

2,052 results found

Post

Replies

Boosts

Views

Activity

CSV to SwiftUI
Hello all, I want to create an app right now that can generate SwiftUI views from csv tables. They have two columns, one with a name and the other contains a hex color code (e.g. Apple,#FFFFFF). I want to read the csv file and then use the first column of each row as text and the second row of the column as the color of the text. But I cannot seem to get this to work. Currently I read the csv with: var filecontent = String(contentsOf: file); where file is defined as a URL(fileURLWithPath: „colors.csv“) How do I now separate the two columns from each other and how do I implement this in a ForEach struct to get this kind of „prodcedural“ item generation?
3
0
1.7k
Dec ’22
Reply to CSV to SwiftUI
I must have been imprecise, my problems are: I don’t know how to read the two different columns per row of a csv into two seperate lists I want to have one vstack containing a scrollable list of all the company names in the corresponding color. E.g. with the csv file: Apple,#FFFFFF Adobe,#FF0000 I want a white text element reading “Apple” and a red text with “Adobe underneath
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’22
Reply to CSV to SwiftUI
How do I now separate the two columns from each other You could use a HStack . how do I implement this in a ForEach struct If I understand correctly, I would create 2 computed var to hold each of the columns content. And use these var in 2 ForEach in the HStack
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’22
UISplitViewController broken when in tab view controllers
I'm trying to rebasline my app to iOS 14. My app's main entry point for the UI is a tab view controller. Three of its four children are then split view controllers. I configured those to 'all visible'. On iPad, this shows both master/detail at all times and on iPhone, you get the collapsed behavior. Just like the Settings app. Anyhow, I've removed the deprecations and migrated the split view controllers to use the new properties: Style of Double Column, Display Mode of One Column Beside, and Behavior of Tile. On iPad, the split view controllers will always be collapsed as if they are running on a compact device. If I make a sample project with the same exact split view controller (along with its configuration as above), but make this SVC the main entry point of the app, all is well on both iPad and iPhone. Collapsed interface only happens on iPhone (compact). But when I change the sample project to have the SVC now a child of a tab view controller, it breaks (always collapsed on all devices)
Topic: UI Frameworks SubTopic: UIKit Tags:
3
0
3.0k
Dec ’22
Reply to Driving NavigationSplitView with something other than List?
There seems no way to work with NavigationSplitView other than List at first column for now, but I think adding a empty List with selection parameter can solve this problem almostly. Here's my solution: var categories : [Category] // can be replaced to NavigationPath @State var path : Category? = nil @State var subpath : Item? = nil var row = [ GridItem(), GridItem(), GridItem() ] var body: some View { NavigationSplitView { LazyVGrid(columns: row) { ForEach(categories) { category in Button(category.title) { path = category } // can use NavigationLink with value parameter, .onTapGesture, etc. } } // coordinates with the NavigationSplitView via selection parameter. List(selection: $path) {} } content: { // MiddleSidebarView(category: path, selection: $subpath) } detail: { // ... } } You can resize or hide List, but always have to be active while navigation feature is needed.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’22
Filling in a MTLAccelerationStructureInstanceDescriptor
While translating the Accelerating Ray Tracing Using Metal sample project into Swift, I have run into an issue within the createAccelerationStructures function. I am trying to fill in the first three rows of the instance transformation matrix. In the Objective C example, it looks like: for (int column = 0; column < 4; column++) tfor (int row = 0; row < 3; row++) ttinstanceDescriptors[instanceIndex].transformationMatrix.columns[column][row] = instance.transform.columns[column][row]; The matrix targeted is a MTLPackedFloat4x3. It has defied me pulling out the needed elements from my instance transform and placing them in the descriptor. I have tried the obvious: for column in 0..<( 4 ) t{ tfor row in 0..<( 3 ) tt{ ttanInstanceDescriptorPointer.pointee.transformationMatrix.columns[column][row] = aNodeInstance.transform.columns[column][row] tt} t} I have tried more obscure ideas related to simd matrices and Swift. The compiler err
3
0
1.1k
Dec ’22
Reply to Filling in a MTLAccelerationStructureInstanceDescriptor
@OOPer, thx for sharing your code. @JL, in a one-to-one port of Apple‘s ray tracer sample (Accelerating ray tracing using Metal) one would use the transpose of the matrix because the sample uses row-first order and MTLAccelerationStructureInstanceDescriptor.transformationMatrix expects column-first. anInstanceDescriptorPointer.pointee.transformationMatrix = MTLPackedFloat4x3(aNodeInstance.transform.transpose) Without transpose the render result seems to be a single Cornell Box but in fact are nine instances stacked at the same position. A bit late, but in case anyone else will come across…
Topic: Graphics & Games SubTopic: General Tags:
Dec ’22
Missing required column 'label' in json. at "HandPoseAssests.json"
I have created the .json file according to the https://developer.apple.com/documentation/createml/building-an-object-detector-data-source here is my .json file below { imagefilename:Five Fingers.HEIC, annotation: [ { coordinates: { y: 156.062, x: 195.122, height: 148.872, width: 148.03 }, label: Five Fingers } ] }, { imagefilename: One Finger.HEIC, annotation: [ { coordinates: { y: 156.062, x: 195.122, height: 148.872, width: 148.03 }, label: One Finger } ] }, { imagefilename: Two Finger.HEIC, annotation: [ { coordinates: { y: 156.062, x: 195.122, height: 148.872, width: 148.03 }, label: Two Finger } ] }, { imagefilename: Four Finger.HEIC, annotation: [ { coordinates: { y: 156.062, x: 195.122, height: 148.872, width: 148.03 }, label: Four Finger } ] } ] but it shows error as Missing required column 'label' in json. at NameOfJsonFile.json Were am I Wrong
2
0
1.4k
Dec ’22
Implement pinch gesture on a SwiftUI's scrollable LazyVGrid
Good day! Question How can we implement pinch gesture in SwiftUI and solve the gesture limitation from MagnificationGesture Description I'm trying to implement a pinch gesture recognizer on a scrollable LazyVGrid in a SwiftUI-based application, however the pinch gesture has usually been intercepted by the scroll gesture and makes it significantly harder to trigger than using UIKit's UIPinchGestureRecognizer. Here're my findings after a few tests. MagnificationGesture: can detect the pinch gesture when two fingers are dragging at the same time. UIPinchGestureRecognizer: can detect the pinch gesture when two fingers are touching and at least one finger is dragging. Cases tried ScrollView + LazyVGrid + MagnificationGesture Result: difficult to trigger as described ScrollView { LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 3)) { ForEach(aryItems) { item in Text(item.photoId) .border(Color.black, width: 1) } } } .highPriorityGesture(MagnificationGesture() .onChanged { value in print(te
1
0
2.2k
Dec ’22
Reply to Issue with string
I figure out the issue but still unable to fix it. Firstly, I made it stop working with me by replicating all the steps the user do. Once the data is read from the SQLite table from a field type string (text typed in SQLite) using sql_column_text() function the result itself contains literal text of Optionaland will break everything. real code when I am attempting to fix, reading user department: let stringValue = String(cString: sqlite3_column_text(Statement, index)) // attempt This will show in the debugger as Optional(Dev team) and the UI where the user changes the information, also shows exactly that way! All of this trouble after updating to XCode 5 (original was done with version 4). I opened the database using a 3rd party software and these characters are there! Here how I read the data: struct ColumnValue { var Column: String var Value: Any? // Need to be any because will support int, float, string at least.. using Any or Any makes no difference } var ResultSet: [ColumnValue] var columnValue:
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’22
Reply to CoreML Performance Report Mean Latency
Hi, yes you can access this data through the Instruments trace that Xcode records when it creates a Core ML Performance Report. Steps: Click on Open in Instruments in the top right corner Click on the Core ML track on the left side In the Model Activity Aggregation view below, expand * All * You should see a column that gives you the average for stats like Load/Compile/Prediction etc Hope that helps, please let us know if you encounter any issues with this. Thanks.
Topic: Machine Learning & AI SubTopic: General Tags:
Dec ’22
SwiftUI - Nested links within NavigationStack inside a NavigationSplitView not working
I'm playing around with the new navigation API's offered in ipadOS16/macOS13, but having some trouble working out how to combine NavigationSplitView, NavigationStack and NavigationLink together on macOS 13 (Testing on a Macbook Pro M1). The same code does work properly on ipadOS. I'm using a two-column NavigationSplitView. Within the 'detail' section I have a list of SampleModel1 instances wrapped in a NavigationStack. On the List I've applied navigationDestination's for both SampleModel1 and SampleModel2 instances. When I select a SampleModel1 instance from the list, I navigate to a detailed view that itself contains a list of SampleModel2 instances. My intention is to navigate further into the NavigationStack when clicking on one of the SampleModel2 instances but unfortunately this doesn't seem to work. The SampleModel2 instances are selectable but no navigation is happening. When I remove the NavigationSplitView completely, and only use the NavigationStack the problem does not arise, and i can suc
3
0
4.4k
Dec ’22