Post

Replies

Boosts

Views

Activity

Reply to How to add a search bar to a list?
I may be mistaking what you mean by doesn't work, so assume showing a search bar would be your primitive purpose here. Please try something like this: struct ContentView: View { var body: some View { NavigationView { TabView{ VStack{ List{ Text("aaa") Text("bbb") Text("ccc") } } .tabItem({ Text("tab1") }) VStack{ Text("tab2") } .tabItem({ Text("tab2") }) } .searchable(text: .constant("")) //<- `searchable` added to `TabView` } } } In your code, TabView is the only child view of NavigationView. And searchable modifier needs to be placed on any of the direct child view of NavigationView, or on the NavigationView itself.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to Couldn't parse json file as array
Thanks for showing the details. So, it's Building Lists and Navigation, Section 2 Create the Row View, Step 4, OK? You may need to go back to Section 1 Create a Landmark Model and check if your Landmark.swift is correct: import Foundation import SwiftUI import CoreLocation struct Landmark: Hashable, Codable { var id: Int var name: String var park: String var state: String var description: String private var imageName: String var image: Image { Image(imageName) } private var coordinates: Coordinates var locationCoordinate: CLLocationCoordinate2D { CLLocationCoordinate2D( latitude: coordinates.latitude, longitude: coordinates.longitude) } struct Coordinates: Hashable, Codable { var latitude: Double var longitude: Double //<- } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to How to rotate this photo from imagePickerController 90 degrees?
What is resizedImageWithContentMode:bounds:interpolationQuality:? As far as I know, UIImage does not have such a method. I guess it is not properly handling imageOrientation. You may need to update the implementation of the method or modify the orientation by yourself. You say sets it to a UIImage property, but your imagePickerController:didFinishPickingMediaWithInfo: sets the image into a UIImageView, not to a UIImage property, that prevents writing more detailed answer.
Topic: UI Frameworks SubTopic: UIKit Tags:
Oct ’21
Reply to How to implement isUserInteractionEnabled
If you mean var isUserInteractionEnabled: Bool { get set } as the provided code, it is not something to use, but to understand what it is. It explains that isUserInteractionEnabled is a read-write property of type Bool. To use isUserInteractionEnabled, you may need to write something like this: import UIKit class ViewController: UIViewController { @IBOutlet var imageView: UIImageView! //... override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. imageView.isUserInteractionEnabled = true //... } //... } You should better show your code when you ask something, that explains how experienced you are and helps getting better answers which will fit for your code. And to make a good communication in the forums, you should better reply to answers or comments to your posts.
Topic: UI Frameworks SubTopic: UIKit Tags:
Oct ’21
Reply to How do you form shapes in Xcode? Swift Playgrounds book.
Unfortunately, many of the components used in the Shapes book are Swift Playgrounds only or the Shapes book only. You can freely expand or modify the Shapes book and create a circle and set in a scene in the book as described in other parts of the book. But you need to do things in a different way in a UIKit app in Xcode. You may need to find a good tutorial of SpriteKit.
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’21
Reply to How to add a search bar to a list?
I may be mistaking what you mean by doesn't work, so assume showing a search bar would be your primitive purpose here. Please try something like this: struct ContentView: View { var body: some View { NavigationView { TabView{ VStack{ List{ Text("aaa") Text("bbb") Text("ccc") } } .tabItem({ Text("tab1") }) VStack{ Text("tab2") } .tabItem({ Text("tab2") }) } .searchable(text: .constant("")) //<- `searchable` added to `TabView` } } } In your code, TabView is the only child view of NavigationView. And searchable modifier needs to be placed on any of the direct child view of NavigationView, or on the NavigationView itself.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to UserDefaults not being saved in Simulator only
I created a simplified project and tested with iOS 15.0 simulator (iPhone 8 Plus)/Xcode 13, but I could not reproduce the issue. There may be some problem in your code. Can you create a simplified project to reproduce the issue and show all the code of it?
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to App Name/ Brand Name already being used
You should better try the Contact Us page of App Store Connect asking how you can go along with your issue. But, in the mean time, you may need to change the app name than the android version. Apple would never care about any Android things.
Replies
Boosts
Views
Activity
Oct ’21
Reply to uicolloectionView mulit selection working weird
Can you show a complete code to reproduce the issue?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Weird fullscreencover and sheet behaviour iOS 15?
You should better include the code as text, unless it is too big.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Screen blinking when key press
I may have been misinterpreting your post. Hope you can solve your issue soon. Good luck.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Couldn't parse json file as array
Thanks for showing the details. So, it's Building Lists and Navigation, Section 2 Create the Row View, Step 4, OK? You may need to go back to Section 1 Create a Landmark Model and check if your Landmark.swift is correct: import Foundation import SwiftUI import CoreLocation struct Landmark: Hashable, Codable { var id: Int var name: String var park: String var state: String var description: String private var imageName: String var image: Image { Image(imageName) } private var coordinates: Coordinates var locationCoordinate: CLLocationCoordinate2D { CLLocationCoordinate2D( latitude: coordinates.latitude, longitude: coordinates.longitude) } struct Coordinates: Hashable, Codable { var latitude: Double var longitude: Double //<- } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Couldn't parse json file as array
The page "Introducing SwiftUI" has several tutorials and each tutorial has several sections. So, there are many Step 4s. Can you clarify in which tutorial and in which section you get that message?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Data struct not working
Seems you have not shown all the code you get the error you described. Please do not hesitate to show the whole code, I guess it may be less than a few hundreds of lines.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Lost Source Code
No way. Re-construct it from scratch.
Replies
Boosts
Views
Activity
Oct ’21
Reply to Anyway I could disable camera access from an app?
Just remove the code accessing camera.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to How to rotate this photo from imagePickerController 90 degrees?
What is resizedImageWithContentMode:bounds:interpolationQuality:? As far as I know, UIImage does not have such a method. I guess it is not properly handling imageOrientation. You may need to update the implementation of the method or modify the orientation by yourself. You say sets it to a UIImage property, but your imagePickerController:didFinishPickingMediaWithInfo: sets the image into a UIImageView, not to a UIImage property, that prevents writing more detailed answer.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to How to implement isUserInteractionEnabled
If you mean var isUserInteractionEnabled: Bool { get set } as the provided code, it is not something to use, but to understand what it is. It explains that isUserInteractionEnabled is a read-write property of type Bool. To use isUserInteractionEnabled, you may need to write something like this: import UIKit class ViewController: UIViewController { @IBOutlet var imageView: UIImageView! //... override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. imageView.isUserInteractionEnabled = true //... } //... } You should better show your code when you ask something, that explains how experienced you are and helps getting better answers which will fit for your code. And to make a good communication in the forums, you should better reply to answers or comments to your posts.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Xcode 13 not allowing the use of colorLiteral
Seems to be the known issue (at least, known by us developers): Color literal not displaying as Color Swatch? You should better send a bug report to Apple.
Replies
Boosts
Views
Activity
Oct ’21
Reply to How do you form shapes in Xcode? Swift Playgrounds book.
Unfortunately, many of the components used in the Shapes book are Swift Playgrounds only or the Shapes book only. You can freely expand or modify the Shapes book and create a circle and set in a scene in the book as described in other parts of the book. But you need to do things in a different way in a UIKit app in Xcode. You may need to find a good tutorial of SpriteKit.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21