My code is import SwiftUI struct ContentView: View { var emojis = [🚂, 🤡, 🚀, 🚁, 🚕, 😅, ✅, 👍, 🥳, 🎃] @State var emojiCount = 6 var body: some View { VStack { ScrollView { LazyVGrid(columns: [GridItem(.adaptive(minimum: 65))]) { ForEach(emojis[0.. 1 { emojiCount -= 1 } }, label: { Image(systemName: minus.circle) }) } var add: some View { Button { if emojiCount < emojis.count { emojiCount += 1 } } label: { Image(systemName: plus.circle) } } } struct CardView: View { var content: String @State var isFaceUp: Bool = true var body: some View { ZStack { let shape = RoundedRectangle(cornerRadius: 20) if isFaceUp { shape.fill().foregroundColor(.white) shape.strokeBorder(lineWidth: 3) Text(content) .font(.largeTitle) } else { shape.fill() } } .onTapGesture { isFaceUp = !isFaceUp } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() .preferredColorScheme(.light) ContentView() .preferredColorScheme(.dark) } } Then I get Actually, the spacing between rows is t
Search results for
column
2,062 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hello, Amateur developer here. I dusted off a hobby core data app coded mostly under OSX 10.7, and which supported undo for free (as Apple say it). It still works when I build it with recent Xcode versions, except that it no longer supports undo. To understand why, I coded the most basic objective-C, core data (not document-based) app. In short, a single table view with a single column bound to an NSArray Controller set in entity name mode and bound to the managed object context. The core data model has a single entity class with a single NSString attribute (called name, and which the table view column shows). It all works well, I can add and remove entities, and change their names from the table. Changes are saved normally... except there is nothing I can undo. The undo menu item is greyed out. I checked that my App Delegate implements the windowWillReturnUndoManager method and that this selector is called regularly. So to check that the undo manager sees anything to undo, I added this meth
Hi. I am having issues with json parsing. all my source data use double quote except for one. here is the sample do { let json = [['16772', 'Cebu', 'Philippines']] if let jsonArray = try JSONSerialization.jsonObject(with: Data(json.utf8), options: []) as? [[Any]] { print(Hello World) } } catch { print(error) } if the json string is let json = [[16772, Cebu, Philippines]] it works ok. but if it is single quote, then it gives out the error message Error Domain=NSCocoaErrorDomain Code=3840 Invalid value around line 1, column 2. UserInfo={NSDebugDescription=Invalid value around line 1, column 2., NSJSONSerializationErrorIndex=2} What am i missing to enable parsing single quote normally? Thoughts?
I don’t think there’s a way to do that but, if you know that the names are unique, you can rename the columns after the join. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com
Topic:
Programming Languages
SubTopic:
Swift
Tags:
I use Core Data with two entities: Set and Link. Both entities contain a UUID id. Sets can contain 1 or more Links and this is represented in a 1-many relationship When the user wants to delete ALL links, this code is called for link in learningSet.webLinksArray.reversed(){ container.viewContext.delete(link) } do{ try container.viewContext.save() } catch let error { print(Failure deleting all links } Here is the view code that renders link if !learningSet.webLinksArray.isEmpty{ LazyVGrid(columns: columns, alignment: .center, spacing: 16, pinnedViews: []) { ForEach(learningSet.webLinksArray, id: .id) { link in RichWebLinkView(webLink: link) } } } It all works, but I get the following error/warning in the console ForEach, _FlexFrameLayout>>: the ID nil occurs multiple times within the collection, this will give undefined results! LazyVGridLayout: the ID nil is used by multiple child views, this will give undefined results! It's unclear why the LazyVGrid is even being re-rendered when the
Hi, I've just finished replacing to NavigationStack, but I'm having trouble with this issue. The following simple sample code works on iOS 16.0 production, but it doesn't work on iOS 16.1 beta. When navigationDestination(isPresent:) is called, Xcode displays runtime warning message, but I cannot understand what the means. A `navigationDestination(isPresented:content:)` is outside an explicit NavigationStack, but inside the detail column of a NavigationSplitView, so it attempts to target the next column. There is no next column after the detail column. Did you mean to put the navigationDestination inside a NavigationStack? I didn't use NavigationSplitView and navigationDestination(isPresent:) is inside NavigationStack. Could someone please point out the problem with this code? Or is it a SwiftUI bug? Test environment Xcode Version 14.1 beta 2 (14B5024i) iPhone SE (3rd gen) (iOS 16.1) Sample Code @main struct StackViewSampleApp: App { var body: some Scene { WindowGroup { Navi
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?
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:
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:
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)
NavigationView was deprecated but was replaced by two new views: NavigationStack (single column) and NavigationSplitView (multiple columns). In your case, you should just use a NavigationStack where you would have otherwise used a NavigationView.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
Does your app use column-style layouts(for iOS 14 and later) of UISplitViewController or a classic interface style? I guess the classic interface style might be the problem.
Topic:
UI Frameworks
SubTopic:
UIKit
Tags:
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:
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
@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: