Search results for

SwiftUI List performance

50,605 results found

Post

Replies

Boosts

Views

Activity

SwiftUI Cloudkit - simple list records from public Db in view
HI All,i am brand new to this and am just starting to learn about swiftui in 2020 so have no knowledge of everything that came before.I have created an app that uses cloudkit. I have a public database with some test data in.All i am wanting is a very basic explanation of how to get that data from the cloudkit public database into a list in my app.I have a a record type called Shoes, in the record i have (brand, name, size)I would like the user to have a list of all shoes that appeer in that database.I would also appreciate filenames to go along with this if there is code in more than one file as i have been getting a little lost with the best practices of where to put code.I know this is a big ask but i cannot find anything simple and strightforward out there in this new iteration of a language.Thanks In Advance,Kind RegardsAdam
2
0
1.2k
Jun ’20
Universal Links Camera does not pass url to .onOpenURL (perform :) method SwiftUI Xcode
Hello, I connected Universal Links between the website and the application, everything was done according to the official documentation, and everything works fine, when the site is launched, safari offers to launch the application, there is also a banner above the launch page. In SwiftUI, I listen to the URL via .onOpenURL (perform :), everything works, but if the link is encoded in a QR code and scanned through the camera, a plate will appear prompting you to go to the application, and it goes, but only does not pass the URL to the .onOpenURL method (perform: ) . What could be the problem ?
3
0
5.2k
Feb ’21
tvOS SwiftUI: TabView > View with List of NavigationLinks
I have a TabView to navigate between 5 sections of a tvOS app. 3 of the 5 sections are Views that present a List of NavigationLinks. I can swipe down into the List to select and option ... but swiping up to get back into the TabView is a no go; I'm locked into the List in terms of swiping. I have to click Menu to get back up into the TabView. Does anyone know a way around this? I'm not sure if this is a bug. With some testing, I've found it behaves exactly like I want if I dive into one of the NavigationLinks in the List. Here is a video showing the issue https://www.dropbox.com/s/eudtl6eik60lrry/RLO-RealEstateListLockDemo-720.mp4?dl=0
1
0
913
Nov ’21
Restoring the detail view for an offscreen row in a List with SwiftUI's state restoration
I have a NavigationView based app and I've implemented support for SwiftUI's state restoration using @SceneStorage to remember which detail view the user has open, as described in Apple's documentation. It's working correctly if the relevant row in the List is visible when I launch the app. However, if the relevant row is initially scrolled offscreen, the detail view doesn't get pushed until I scroll down so that the row is onscreen. I see the same behavior in Apple's sample app, which uses a LazyVGrid (I had to add some additional data to the products.json file such that the main content view had to scroll). Restoring the detail view when the row is offscreen does work in both my app and in Apple's sample app if I replace the List / LazyVGrid with a plain VStack. Is this a known limitation of SwiftUI's state restoration with List and the lazy stack / grid views?
0
0
851
Jun ’21
Having trouble changing updating swiftUI List display when sort order changes...
Hello, I am attempting to present a list of items in SwiftUI sorted by when they were last used. Current behaviour: user sees a List of items, sorted with most recently used at the top user selected item X from the list (navigates to its detail view) user 'uses' item X in the detail view user navigates back to list view expected behaviour: item X at the top of the list actual behaviour: item X is still in its previous location (see code below) When I uncomment line 27, tapping the user button immediately (and unexpectedly) takes the user back to the list view. Is there a way I can leave the user on the detail view, but have the list be sorted when I go back to the list view? thanks! import SwiftUI struct ContentView: View { @ObservedObject var list = ModelList.shared var body: some View { NavigationView { List(list.sorted()) {object in NavigationLink(destination: DetailView(object: object)) { Text(objec
2
0
1.5k
Aug ’20
Reply to application(app,open,options) not being called when used with @UIApplicationDelegateAdaptor
In Emoji Rangers - https://developer.apple.com/documentation/widgetkit/building_widgets_using_widgetkit_and_swiftui we handle it directly on the on SwiftUI view. You shouldn't need @UIApplicationDelegateAdapter to handle the url. var body: some View { NavigationView { List { NavigationLink( destination: DetailView(character: .panda), isActive: $pandaActive) { TableRow(character: .panda) } } .onOpenURL(perform: { (url) in self.pandaActive = url == CharacterDetail.panda.url }) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’20
How to render multiline text in SwiftUI List with correct height?
I would like to have a SwiftUI view that shows many lines of text, with the following requirements:Works on both macOS and iOS.Shows a large number of strings (each string is backed by a separate model object).I can do arbitrary styling to the multiline text.Each string of text can be of arbitrary length, possibly spanning multiple lines and paragraphs.The maximum width of each string of text is fixed to the width of the container. Height is variable according to the actual length of text.There is no scrolling for each individual text, only the whole list.Links in the text must be tappable/clickable.Text is read-only, does not have to be editable.Feels like the most appropriate solution would be to have a List view, with the individual rows wrapping native UITextView/NSTextView.Here’s what I have so far. It implements most of the requirements EXCEPT having the correct height for the rows.import SwiftUI let number = 20 struct ListWithNativeTexts: View { var body: some View { List
8
0
11k
May ’20
iOS 18 SwiftUI List with animation modifier has unexpected behaviour
Noticed in iOS 18 that List element with animation modifier behaves differently. Seems that on first change of the underlying State property List updates all elements and loses its scroll position even if you insert just one element. The following code reproduces the behaviour, if you run it on iOS 17 it will behave as expected, you'll see an element being added to the list with an acompanying animation. On iOS 18 you'll lose your scroll position and judging by the animation it seems to update all the other rows in the list even though only one element of the underlaying State property was inserted. After that first update, list element on iOS will behave as expected. To reproduce the issue scroll down to the ~50th element and tap on a row, compare the behaviour on iOS 17 and iOS 18. import SwiftUI struct ContentView: View { struct ViewState: Equatable { struct Value: Identifiable, Equatable { let id: String var text: String var value: Bool } let list
0
0
489
Dec ’24
Is a distinct BindableObject per row in a SwiftUI List the way to go?
I have a table (i.e. List) with a large number of rows. (Say 1000. Say 10,000. Who knows.). The rows show images which are loaded from a remote server. The images are fetched lazily, so it is highly likely that if one scrolls fast enough, any given row of the table may display not the actual image, but a placeholder until the image is available.Prior to SwiftUI, the way I would do this is have a model backend which, when it loads an image, sends out a signal that an image with path P (i.e. some string identifying the image) is ready. The UITableViewController would have kept a map that says for any existing cell, what image that cell cares about. If the UITableViewController sees that an image that some existing cell cares about has been modified, it would reload JUST THAT ROW (updating a placeholder image, or switching out an activity spinner to the actual image).I believe in SwiftUI that I also want to be that performant: if the backend finishes loading an image, I only t
0
0
545
Sep ’19
Reply to (ForEach-Error)SwiftUI, Firestore getting one collection and matching with another
Hello. I'll try to address the error reported by the compiler first. As stated on Apple List documentation the List type should conform to Identifiable. This is done as SwiftUI needs to know how to identify each and every cell in our list in order to optimize it and perform any operation like displaying, removing cells. That being said it seems by the error you reported that multiple cells have the same id. This is not acceptable since by design the id needs to be different for each cell. This is so SwiftUI can understand which cell is which. I would advise to double-check that the id is different in each Artwork type. In the example below we assign a new unique UUID so that it's almost fully guaranteed that each cell have a different id: struct Artwork: Identifiable { let id = UUID() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’23
SWIFTUI List object .onTapGesture : Continued Version 2
Trying to implement what DTS Engineer posted https://developer.apple.com/forums/thread/791837?login=true But This time with REST API & DataModel , This is an Absolute Newbie SWIFTUI question, Somehow my data model cannot get it working due to my lack of understanding !!, please help Error Candidate requires that 'SWIFT_DBG_Workflow_Trans_Datamodel_Data_ListViewModel' conform to 'Identifiable' (requirement specified as 'Data.Element' : 'Identifiable') (SwiftUICore.ForEach) Sorry for the long post, all of the source code listed below //Datamodel -- scripts below import Foundation struct SWIFT_DBG_Workflow_Trans_Datamodel_Response: Decodable { let SWIFT_DBG_Workflow_Trans_Datamodel_Rows: [SWIFT_DBG_Workflow_Trans_Datamodel_Data] private enum CodingKeys: String, CodingKey { case SWIFT_DBG_Workflow_Trans_Datamodel_Rows = rows // root tag: REST API } } struct SWIFT_DBG_Workflow_Trans_Datamodel_Data: Decodable { let mst_rec_id: Int32 let work_task:String private enum CodingKeys: String, CodingK
Topic: UI Frameworks SubTopic: SwiftUI
3
0
184
Jul ’25
SwiftUI ScrollView enabling “re-order”/“move” items in a ScrollView as one can in a List?
Is it possible to re-order/move items in a ScrollView as one can in a List? I have playground below which compiles/run fine, however the onDelete / onMove does does visualise any delete button or hamburger lines for dragging/moving?Is there a way to get my code working here so at least the onMove concept works?Note - I note that both List and ScrollView (I think) support protocol DynamicViewContent, so was assuming it should work(?)Image after running code: https://i.stack.imgur.com/c5R8g.pngCode (Playgrounds)import SwiftUI import PlaygroundSupport let modelData: [String] = [Eggs, Milk, Bread] struct ListTestNoDelete: View { private func move(from uiStartIndexSet: IndexSet, to uiDestIndex: Int) { print(On Move) } private func delete(at offsets : IndexSet) { print(On Delete) } var body: some View { NavigationView { VStack { ScrollView { ForEach(modelData, id: .self) { str in HStack { Image(systemName: square) Text(str) Spacer() }.padding(.horizontal, 3) } .onMove(perform: se
0
0
1.6k
Apr ’20