Search results for

swiftui

16,623 results found

Post

Replies

Boosts

Views

Activity

NavigationLink appears as unresolved, has it been deprecated?
Going through some learning materials on SwiftUI, I'm trying to wrap a view inside a NavigationLink but it appears unresolved.struct LandmarkList: View { var body: some View { NavigationView { List(landmarkData) { landmark in NavigationLink(destination: LandmarkDetail()) { LandmarkRow(landmark: landmark) } }.navigationBarTitle(Text(Landmarks)) } } }This is the error I get:Use of unresolved identifier 'NavigationLink'; did you mean 'NavigationView'?
3
0
843
Jul ’19
SwiftUI: UITableViewCell.AccessoryType.detailDisclosureButton
I am trying to convert the UI an App of mine to SwiftUI.My app displays an UITableView, where the cells have the propertyUITableViewCell.AccessoryType.detailDisclosureButtonThat means: An information button and a disclosure (chevron) control are displayed on every row.Pressing the button shows Information about the cell Data (modal)Pressing the chevron pushes a Detail-View onto the NavigationView-Stack and displays it.How do I achieve this behavior using SwiftUI?
2
0
3.9k
Jul ’19
How long does it usually take to get deprecation indications into documentation?
Xcode 11b4 is telling me that SwiftUI's relativeWidth property for views is deprecated, but it shows up in a LOT of documentation as if it's still in use.I do this app thing as a part-time hobby, and I'm so excited for SwiftUI's potential, and I know that it's beta, but it seems like having the beta docs synched with the beta SDK would make the learning process a tiny bit less frustrating.
3
0
907
Jul ’19
Use reusability of views in List like in TableView
Hi,I'm working on a app with a List as my main view. Previously I was using a TableViewController to present content. I wanted to know if there is a way to have reusable rows in List to make it more optimized like reusable cells, because this app is loading a lot of rows from an API (list of users and posts) which can be infinite as the user scrolls in the view. I'm currently doing it this way:import SwiftUI struct TimelineView : View { // The custom class containing users and posts @ObjectBinding var timeline: Timeline var body: some View { List { // Show users Section(header: Text(timeline_section_users)) { ForEach(timeline.userObjects) { user in // The view for a user UserView(user: user) } } // Show posts Section(header: Text(timeline_section_posts)) { ForEach(timeline.postObjects) { post in // The view for a post PostView(post: post) } } // Load more Section { Text(Loading...).onAppear() { // When this text appears, we call the API for more content self.timeline.loadContent() } } } .listStyle(.g
0
0
551
Jul ’19
Best Practice to subscribe to a Publisher in SwiftUI
Hi,I am experimenting with SwiftUI and Combine after watching https://developer.apple.com/videos/play/wwdc2019/226/ ( Data Flow Through SwiftUI ).So I created a Publisher to load some data via network call, something like this:var countriesPublisher: AnyPublisher<[Country], Never> = { let urlSession = URLSession.shared let url = URL(string: https://www.ralfebert.de/examples/countries.json)! return urlSession .dataTaskPublisher(for: url) .map { $0.data } .decode(type: [Country].self, decoder: JSONDecoder()) .assertNoFailure() // todo: no error handling right now .receive(on: RunLoop.main) .eraseToAnyPublisher() }()And I want to use this in a SwiftUI view. Now the WWDC talk recommended to use @State to hold the data, subscribe to it via onReceive and copy it to the internal state. This works, f.e.:struct CountriesListView: View { @State var countries = [Country]() var body: some View { List(countries) { country in Text(country.name) } .onReceive(countriesPublisher) { countries i
3
0
11k
Jul ’19
SwiftUI previews stopped working everywhere after using EnvironmentObject
I added @EnvironmentObject to a property in a SwiftUI view as part of the official tutorial Adding User Interaction and added the .environmentObject modifier to the preview. However, I get the error:Cannot preview in this file - MyApp.app may have crashedThis error now appears in every SwiftUI project, even ones without EnvironmentObject or a blank SwiftUI template, so I cannot use previews. I have tried rebooting several times, and made sure the command line tools are set to Xcode 11. How can I fix this? Thanks!
14
0
18k
Jul ’19
Reply to SwiftUI previews stopped working everywhere after using EnvironmentObject
Did you do an option-clean-build Folder in XCode ?Did you read the release notes of XCode 11.4:SwiftUI Tutorials Known IssuesAfter following Section 7, Step 7 in the Building Lists and Navigation tutorial in Xcode, you might encounter an error in your projectʼs SceneDelegate.swift file. (51334559)Workaround: Update line 14 of SceneDelegate.swift to use LandmarkList instead of LandmarkDetail:window.rootViewController = UIHostingController(rootView: LandmarkList())After following Section 5, Step 3 in the Handling User Input tutorial in Xcode, you might encounter an error in the preview provider. (51341785)Workaround: Undo the change to the LandmarkDetail initializer, so that you only add the environmentObject(_:) modifier:struct LandmarkDetail_Preview: PreviewProvider { static var previews: some View { LandmarkDetail(landmark: landmarkData[0]) .environmentObject(UserData()) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’19