Post

Replies

Boosts

Views

Activity

NavigationLInk
I have an array with 10 different categories. So I create NavigationLink for each of them, calling MyListView and passing data about the category. NavigationView { List(categories) { category in NavigationLink(destination:           MyListView(category: category) )             {           CategoryRow(category: category)   } } } So when I click in one of these 10 categories, I will call MyListView. Inside MyListView I have a call to the API bringing a lot of information about the chosen category. The problem here is, even before clicking in any category, MyListView is being called and the API is called for all the 10 categories. I only want to call MyListView and the API inside it, after selecting the category. Whats the problem here ? Thx
3
0
655
Sep ’21
Open View using Button
When I use TabView and select a TabItem, a chosen View will open right away. TabView {   HomeView()          .tabItem {             Image(systemName: "house")           Text("Home")           } } Now I am trying to do the same, using button. However with button, the chosen View will open under .sheet or .fullScreenCover. Button(text) { self.isPresented.toggle() } .sheet(isPresented: $isPresented) { self.content } How can I open the View using button, the same way it's opened using TabBar ? Thx
1
0
388
Sep ’21
TabBar and Views
I have a TabBar with 5 different views for each TabBar item. All these 5 views have long content wrapped in a ScrollView. So let's say I chose my 2nd TabBar item and scroll on this view. Then I move away to another view and when I hit the 2nd TabBar item again, I want this view scrolled to the top and not at the position I left on the first visualization. How can I do that? Thx
0
0
377
Nov ’21
Navigation Bar Color
I am trying to change the navigation bar background color of my view. Init() {    let coloredAppearance = UINavigationBarAppearance()     //coloredAppearance.configureWithTransparentBackground() //It doesnt matter what I use in here, it continues the same coloredAppearance.backgroundColor = UIColor(red: 202.0/255.0, green: 52.0/255.0, blue: 86.0/255.0, alpha: 1.0)     coloredAppearance.titleTextAttributes = [.foregroundColor: UIColor.white]      UINavigationBar.appearance().standardAppearance = coloredAppearance UINavigationBar.appearance().compactAppearance = coloredAppearance UINavigationBar.appearance().scrollEdgeAppearance = coloredAppearance      UINavigationBar.appearance().tintColor = .white However if you get the red, green, blue, and alpha used above, you will see the color is being shown slightly different on the NavigationBar. What's the reason for that ? Thx
1
0
427
Nov ’21
Button inside Form
I have a form and at the end of it, a button. Form { Section { } //close section button } //close form However, the button is appearing surrounded by white space, like inside a textbox. What's the reason for that?
1
0
429
Nov ’21
TabBar 2 clicks
I have a TabBar with 8 items. And as everybody knows, more than 5 makes the 5th item the MORE button and it's perfect. The problem is when I hit it, the button just blinks. If I hit again, then the other options are shown. Why ? Thx
1
0
401
Nov ’21
TabBar Transitions
I have a TabBar with 3 items: Home ScrollView Products NavigationView Users NavigationView When clicking on the tabBar buttons, I will go back to the related view. However, at the point where I had left. I would like to every time I move to a different tab, it starts fresh like 1st time. a) If it's a scrollview, after coming back to the tab I would like the view scrolled to the top. b) If it's a navigationView, after coming back to the tab, I would like to scroll to the top and move to the Navigation root list. How can I do it. Thx folks
0
0
370
Dec ’21
API Error
I have this API call in my application. For some reason, the response is coming back nil. If I try the right URL, a JSON will be returned and all the nodes filled out. So I'm trying to get the error inside the if let error = error { but even putting a breaking point in there, the code is never reached. What am I doing wrong ? Thanks func getProductById(productId: Int, completion: @escaping (ProductModel) -> ()) {     guard let url = URL(string: "https://mysite/api/products/82") else { return }    var request = URLRequest(url: url)     request.httpMethod = "GET"     request.setValue("application/json; charset=UTF-8", forHTTPHeaderField: "Content-Type")    URLSession.shared.dataTask(with: request) { (data, request, error) in       if let data = data {         print("data")      }      if let error = error {         print("error")      }       guard let data = data else { return }      do {         let product = try! JSONDecoder().decode(ProductModel.self, from: data)         DispatchQueue.main.async {           completion(product)         }       }      catch {         print(error)       }    }     .resume()
2
0
1.5k
Aug ’21
Published Vars
I have an ObservableObject class that can return 2 different @published vars (product or products), depending on the function I call. But when I define the published vars, I am having an error message "Missing argument for parameter 'from' in call". It just happens for the first published var. What's the mistake? Thx class ProductStore: ObservableObject {   @Published var product = ProductModel() //getting error here   @Published var products: [ProductModel] = []   func getProducts() {     ProductApi().getProducts() { (products) in       self.products.append(contentsOf: products)     }   }   func getProductById(productId: Int) {     ProductApi().getProductById(productId: productId) { (product) in       self.product = product     }  } }
2
0
734
Aug ’21
DateFormatter - String to Date
struct MyView: View { var body: some View { //this value is coming from a JSON var myDate = "3000-01-01T08:00:00-08:00" //Here I'm calling my function formatDate, passing my myDate parameter: Text(formatDate(dateString: myDate)) } } func formatDate(dateString: String) -> Date { //first I dont know why my parameter gets here nil   let dateFormatter = ISO8601DateFormatter() //at the dateFormatter, doesnt matter the options I set, the return is always the same.   dateFormatter.formatOptions = [ .withFullDate,     .withFullTime,   ]   let finalDate = dateFormatter.date(from: dateString)!   return finalDate } I just need the get the date string, convert it to the format MM dd, yyyy - hh:mm How can I do it ? Thank you
2
0
692
Sep ’21
Showing Decimal value
I am trying to present a decimal variable containing the value of 66.67. So I am trying to do: Text("\(myVariable, specifier: "%.2f")") //Instance method 'appendinterpolation(_:specifier) requires that Decimal conform to _formtSpecifiable Text("\(myVariable, specifier: "%.2f")" as String) //I receive extra argument specifier in call How can I fix it ? Thx
3
0
917
Sep ’21
Launch Screen Image
I have set in my info.plist file, the background and image I want for my launch screen. The image is 200px x 200px and for some reason, when the launch screen happens, the image gets stretched, not keeping the original size. How can I fix it ? Thank you
4
0
1.6k
Sep ’21
Calling API
The main view on my app brings data from 3 different API calls. So when the app starts, the data are still being returned, so nothing is seen but just a blank space. They are basically a Thumbnail and its title. What would be the best solution for that: Have a temporary thumb and a text like "loading" OR any other approach? Thank you
1
0
781
Sep ’21
Init or body ?
I have a store, but need to call the method inside the body. However the only way it works is if I call it inside init otherwise I have an error. @ObservedObject var store = MyStore() init(category: categoryModel) {     store.getData(categoryId: category.id) //here works } var body: some View {         store.getData(categoryId: category.id) //Here I will have the error: Type '()' cannot conform to 'View' Why ? Thx
1
0
536
Nov ’21
SF Symbols Fill
I am using SF symbols on my TabBar but even though I use the stroke version, it inserts the fill one. ProductsListView()         .tabItem {            Image(systemName: "book")            Text("Products")         } However, the image that shows up when I run the application in the book.fill Why this could be happening? Thx
2
0
2.3k
Nov ’21
NavigationLInk
I have an array with 10 different categories. So I create NavigationLink for each of them, calling MyListView and passing data about the category. NavigationView { List(categories) { category in NavigationLink(destination:           MyListView(category: category) )             {           CategoryRow(category: category)   } } } So when I click in one of these 10 categories, I will call MyListView. Inside MyListView I have a call to the API bringing a lot of information about the chosen category. The problem here is, even before clicking in any category, MyListView is being called and the API is called for all the 10 categories. I only want to call MyListView and the API inside it, after selecting the category. Whats the problem here ? Thx
Replies
3
Boosts
0
Views
655
Activity
Sep ’21
Open View using Button
When I use TabView and select a TabItem, a chosen View will open right away. TabView {   HomeView()          .tabItem {             Image(systemName: "house")           Text("Home")           } } Now I am trying to do the same, using button. However with button, the chosen View will open under .sheet or .fullScreenCover. Button(text) { self.isPresented.toggle() } .sheet(isPresented: $isPresented) { self.content } How can I open the View using button, the same way it's opened using TabBar ? Thx
Replies
1
Boosts
0
Views
388
Activity
Sep ’21
TabBar and Views
I have a TabBar with 5 different views for each TabBar item. All these 5 views have long content wrapped in a ScrollView. So let's say I chose my 2nd TabBar item and scroll on this view. Then I move away to another view and when I hit the 2nd TabBar item again, I want this view scrolled to the top and not at the position I left on the first visualization. How can I do that? Thx
Replies
0
Boosts
0
Views
377
Activity
Nov ’21
Navigation Bar Color
I am trying to change the navigation bar background color of my view. Init() {    let coloredAppearance = UINavigationBarAppearance()     //coloredAppearance.configureWithTransparentBackground() //It doesnt matter what I use in here, it continues the same coloredAppearance.backgroundColor = UIColor(red: 202.0/255.0, green: 52.0/255.0, blue: 86.0/255.0, alpha: 1.0)     coloredAppearance.titleTextAttributes = [.foregroundColor: UIColor.white]      UINavigationBar.appearance().standardAppearance = coloredAppearance UINavigationBar.appearance().compactAppearance = coloredAppearance UINavigationBar.appearance().scrollEdgeAppearance = coloredAppearance      UINavigationBar.appearance().tintColor = .white However if you get the red, green, blue, and alpha used above, you will see the color is being shown slightly different on the NavigationBar. What's the reason for that ? Thx
Replies
1
Boosts
0
Views
427
Activity
Nov ’21
Button inside Form
I have a form and at the end of it, a button. Form { Section { } //close section button } //close form However, the button is appearing surrounded by white space, like inside a textbox. What's the reason for that?
Replies
1
Boosts
0
Views
429
Activity
Nov ’21
TabBar 2 clicks
I have a TabBar with 8 items. And as everybody knows, more than 5 makes the 5th item the MORE button and it's perfect. The problem is when I hit it, the button just blinks. If I hit again, then the other options are shown. Why ? Thx
Replies
1
Boosts
0
Views
401
Activity
Nov ’21
TabBar Transitions
I have a TabBar with 3 items: Home ScrollView Products NavigationView Users NavigationView When clicking on the tabBar buttons, I will go back to the related view. However, at the point where I had left. I would like to every time I move to a different tab, it starts fresh like 1st time. a) If it's a scrollview, after coming back to the tab I would like the view scrolled to the top. b) If it's a navigationView, after coming back to the tab, I would like to scroll to the top and move to the Navigation root list. How can I do it. Thx folks
Replies
0
Boosts
0
Views
370
Activity
Dec ’21
API Error
I have this API call in my application. For some reason, the response is coming back nil. If I try the right URL, a JSON will be returned and all the nodes filled out. So I'm trying to get the error inside the if let error = error { but even putting a breaking point in there, the code is never reached. What am I doing wrong ? Thanks func getProductById(productId: Int, completion: @escaping (ProductModel) -> ()) {     guard let url = URL(string: "https://mysite/api/products/82") else { return }    var request = URLRequest(url: url)     request.httpMethod = "GET"     request.setValue("application/json; charset=UTF-8", forHTTPHeaderField: "Content-Type")    URLSession.shared.dataTask(with: request) { (data, request, error) in       if let data = data {         print("data")      }      if let error = error {         print("error")      }       guard let data = data else { return }      do {         let product = try! JSONDecoder().decode(ProductModel.self, from: data)         DispatchQueue.main.async {           completion(product)         }       }      catch {         print(error)       }    }     .resume()
Replies
2
Boosts
0
Views
1.5k
Activity
Aug ’21
Published Vars
I have an ObservableObject class that can return 2 different @published vars (product or products), depending on the function I call. But when I define the published vars, I am having an error message "Missing argument for parameter 'from' in call". It just happens for the first published var. What's the mistake? Thx class ProductStore: ObservableObject {   @Published var product = ProductModel() //getting error here   @Published var products: [ProductModel] = []   func getProducts() {     ProductApi().getProducts() { (products) in       self.products.append(contentsOf: products)     }   }   func getProductById(productId: Int) {     ProductApi().getProductById(productId: productId) { (product) in       self.product = product     }  } }
Replies
2
Boosts
0
Views
734
Activity
Aug ’21
DateFormatter - String to Date
struct MyView: View { var body: some View { //this value is coming from a JSON var myDate = "3000-01-01T08:00:00-08:00" //Here I'm calling my function formatDate, passing my myDate parameter: Text(formatDate(dateString: myDate)) } } func formatDate(dateString: String) -> Date { //first I dont know why my parameter gets here nil   let dateFormatter = ISO8601DateFormatter() //at the dateFormatter, doesnt matter the options I set, the return is always the same.   dateFormatter.formatOptions = [ .withFullDate,     .withFullTime,   ]   let finalDate = dateFormatter.date(from: dateString)!   return finalDate } I just need the get the date string, convert it to the format MM dd, yyyy - hh:mm How can I do it ? Thank you
Replies
2
Boosts
0
Views
692
Activity
Sep ’21
Showing Decimal value
I am trying to present a decimal variable containing the value of 66.67. So I am trying to do: Text("\(myVariable, specifier: "%.2f")") //Instance method 'appendinterpolation(_:specifier) requires that Decimal conform to _formtSpecifiable Text("\(myVariable, specifier: "%.2f")" as String) //I receive extra argument specifier in call How can I fix it ? Thx
Replies
3
Boosts
0
Views
917
Activity
Sep ’21
Launch Screen Image
I have set in my info.plist file, the background and image I want for my launch screen. The image is 200px x 200px and for some reason, when the launch screen happens, the image gets stretched, not keeping the original size. How can I fix it ? Thank you
Replies
4
Boosts
0
Views
1.6k
Activity
Sep ’21
Calling API
The main view on my app brings data from 3 different API calls. So when the app starts, the data are still being returned, so nothing is seen but just a blank space. They are basically a Thumbnail and its title. What would be the best solution for that: Have a temporary thumb and a text like "loading" OR any other approach? Thank you
Replies
1
Boosts
0
Views
781
Activity
Sep ’21
Init or body ?
I have a store, but need to call the method inside the body. However the only way it works is if I call it inside init otherwise I have an error. @ObservedObject var store = MyStore() init(category: categoryModel) {     store.getData(categoryId: category.id) //here works } var body: some View {         store.getData(categoryId: category.id) //Here I will have the error: Type '()' cannot conform to 'View' Why ? Thx
Replies
1
Boosts
0
Views
536
Activity
Nov ’21
SF Symbols Fill
I am using SF symbols on my TabBar but even though I use the stroke version, it inserts the fill one. ProductsListView()         .tabItem {            Image(systemName: "book")            Text("Products")         } However, the image that shows up when I run the application in the book.fill Why this could be happening? Thx
Replies
2
Boosts
0
Views
2.3k
Activity
Nov ’21