Post

Replies

Boosts

Views

Activity

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 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 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 SwiftUI using UIImagePickerController produces nil UIImage
Any hint ? 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 YourView: View { //... var body: some View { //... .sheet(item: $activeSheet, onDismiss: dismissSheet) { item in PicView(item: item, inputImage: $inputImage) } //... } //... } struct PicView: View { var item: ... @Binding var inputImage: UIImage? var body: some View { switch(item) { case .selectPic: ImagePicker(image: $inputImage) case .editPic: DetailedPicView(inputImage: inputImage) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to How to get single object JSON API in SwiftUI
UPDATE: Assuming you are using my code with Result as is... How do I then get the data from that into a variable?  @State var singleObject: SingleObject? .onAppear { ApiCall().getSingleObject{ result in switch result { case .success(let singleObject): self.singleObject = singleObject case .failure(let error): print(error) } } } You say a single object, you usually do not use an Array for a single object.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Switching Views in SwiftUI with a button.
Your code has several fundamental issues as a SwiftUI source: The body of ContentView contains ContentView (Are you trying sort of recursive view structure?) VStack block is not in body, nor in any other methods or computed properties (You should better keep your code always properly indented.)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Switching Views in SwiftUI with a button.
I've tried doing the method where pressing a button toggles a variable, but it just spits a bunch of errors. You may be doing something wrong. Can you show your code? would I need to make a new SwiftUI file, or could I incorporate the new view into the default ContentView.swift? Anyway, as you like.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21