Post

Replies

Boosts

Views

Activity

Reply to Rearrange collection view cells within it's section
Have you tried implementing collectionView(_:targetIndexPathForMoveFromItemAt:toProposedIndexPath:)? collectionView(_:targetIndexPathForMoveFromItemAt:toProposedIndexPath:) - https://developer.apple.com/documentation/uikit/uicollectionviewdelegate/1618052-collectionview func collectionView(_ collectionView: UICollectionView, targetIndexPathForMoveFromItemAt originalIndexPath: IndexPath, toProposedIndexPath proposedIndexPath: IndexPath) - IndexPath { if originalIndexPath.section == proposedIndexPath.section { return proposedIndexPath //Accept moving to the proposedIndexPath } else { return originalIndexPath //Keep staying at the originalIndexPath } }
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’21
Reply to 256GB enough for mobile development
Depends on your usage. Xcode requires 50GB or more free space when installing/upgrading. The runtimes of iOS Simulator may consume nearly 10GB for each version, To build a small project, some amount of disk space is needed. Hundreds of simple sample code would take some GB of storage. Generally, 256GB would be enough for building and running a few simple projects (and installing tools and SDKs you have mentioned). But you may need to clean up your disk space once in a while, if you need to work with more projects.
Apr ’21
Reply to Getting The Value From a Picker
Yeah, here it is Thanks. The Italicized and bolded part is the code that I am referencing It is very kind marking the point of interest, but code formatting would make it more readable. Please use Code block (icon ``) feature of this site. There may be several ways, but in your case this would work: Picker("Number of People:", selection: $numberOfPeople){ ForEach(1...100, id: \.self) { //- Text("\($0) people") } } When you use ForEach(_:id:), id of each element will be used as a selection value.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to What is the type of a constant that is being implemented into a custom modifier?
In Swift, type names should start with Capital letter. If you have some reason that you cannot follow the basic coding rule of Swift, please re-interpret the following description. You declare icon in your SettingsIconImageStyleUsingSFSymbols as a concrete struct type RowAndIconView. Then there is no choice other than you declare it as RowAndIconView: import SwiftUI struct SettingsIconImageStyleUsingSFSymbols: ViewModifier { 		let icon: RowAndIconView 		func body(content: Content) -> some View { 				Image(icon.systemImageName) 						.resizable() 						.aspectRatio(contentMode: .fit) 						.frame(width: 35, height: 35) 						.padding(7) 						.foregroundColor(icon.foregroundColorOfImage) 						.background(icon.backgroundColorOfImage) 						.cornerRadius(10) 						.padding(5) 		} } extension View { 		func settingsIconViewWithSFSymbols(with icons: [RowAndIconView]) -> some View { self.modifier(SettingsIconImageStyleUsingSFSymbols(icon: icons[0])) 		} } //Or extension View { 		func settingsIconViewWithSFSymbols(with icon: RowAndIconView) -> some View { self.modifier(SettingsIconImageStyleUsingSFSymbols(icon: icon)) 		} }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Question: Swiftui http request without button
"Cannot use mutating member on immutable value: 'self' is immutable." Sorry, I have forgotten one thing. In struct used as View, you need @State in addition to making it var:     @State var dateien = ["word.png", "vi.png", "text.png", "pp.png", "pdf.png", "ordner.png", "ex.png", "datei.png", "bild.png"] (Seems I need to repeat, remove Optional.) Also, you need to remove mutating from doHttpRequest().
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Question: Swiftui http request without button
But I don't get how to use the Array" Dateien" from the Http-Request instead of the example one. It's dateien, not Dateien. In Swift, identifiers are case sensitive, you should better care about that even in non-code context. Assume your print(dateien) (line 85 of doHttpRequest()) shows expected result, you just need to update the property dateien with the local variable dateien. 				self.dateien = dateien To make this work, the declaration of the property dateien (line 19 of ContentView4) needs to be var, not let. By the way, why are you adding Optional to the property declaration of dateien?     let dateien = Optional(["word.png", "vi.png", "text.png", "pp.png", "pdf.png", "ordner.png", "ex.png", "datei.png", "bild.png"]) With declaring it as non-Optional, you can reduce some risky-and-never-want-to-use forced unwrappings (!).     var dateien: [String] = [] Or if you need some initial values:     var dateien: [String] = ["word.png", "vi.png", "text.png", "pp.png", "pdf.png", "ordner.png", "ex.png", "datei.png", "bild.png"]
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Open Modal
Shoudn't the first click also to be passing the selectedEvento ? Why it doesnt happen ? It is a known issue that @State variables do not work when used in the closure of sheet. A possible workaround is making another View from the content of the sheet: struct MyView: View { //... var body: some View { //... .sheet(isPresented: $showModal) { MySheetView(selectedEvento: self.$selectedEvento) } //... } } struct MySheetView: View { @Binding var selectedEvento: Evento? var body: some View { if self.selectedEvento != nil { //open detailView } else { Text("Some Error State goes here") } } } You can find some other threads showing how to workaround the @State and sheet issue, for example: https://developer.apple.com/forums/thread/677454 .
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to How to Sum User-Generated Data
I'm trying to find the sum of a user-generated array by using the following code.  I have this structure on the top of the page with the following data format: Where is the array? To apply reduce, the thing applied needs to be an Array. (Or at least a Sequence.) In your shown code, there aren't any Arrays. Assuming you have an Array of Grade, var grades: [Grade] = [/*...*/] you can write something like this: let total = grades.reduce(0, {$0 + $1.pointsReceived}) By the way, why are you using Implicitly Unwrapped Optionals in your struct? If you know the property can be nil, you should use normal Optionals: struct Grade: Hashable, Identifiable { 		var id = UUID() 		var assessmentName: String? 		var pointsReceived: Double? 		var pointsPossible: Double? } (In this case, you need to update the code to reduce.) Or else, if the property cannot be nil, you should better use non-Optional: struct Grade: Hashable, Identifiable { 		var id = UUID() 		var assessmentName: String 		var pointsReceived: Double 		var pointsPossible: Double }
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Convert HTML to Text
As for now, there's no support for rendering HTML in SwiftUI. You may need to wrap WKWebView or UILabel with NSAttributedString into UIViewRepresentable. You can send a feature request using Apple's Feedback Assistant.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21