Post

Replies

Boosts

Views

Activity

Lazy loading in List (iOS 16, iPhone 14 Pro)
I've seen previous questions asked about iOS 14 and the lazy loading of content inside the List, but it still seems to me that if you use List to store search results, it takes significantly more time to display on the screen than if you use ScrollView with LazyVStack. Maybe it's about how the data is fed to the List input? Or maybe it's the fact that not all content is loaded lazily. I'm open to the idea that text might load lazily, but icons don't.
0
0
641
Feb ’23
Multiple errors with UIActivityViewController in SwiftUI
When I run the code below, a lot of strange errors are output to the console. If you read them, you will notice that they are all referred to some "database". (What nonsense!) I'm guessing it has something to do with the SQLite module. Most likely, the "Context" variable makeUIViewController(context: Self.Context) by the same name is also present in SQLite. If the same code is placed in a new clean project, without dependencies, it will work without errors. Can I specify Context in some other way or restrict the scope of the SQLite module? Or maybe the error is in something else? The library I use: https://github.com/stephencelis/SQLite.swift Console output: 2021-12-11 02:01:40.253894+0300 dia[964:95878] [Fetching] LPFileMetadataProviderSpecialization failed to retrieve a thumbnail from QuickLookThumbnailing (Error Domain=QLThumbnailErrorDomain Code=0 "Could not generate a thumbnail") 2021-12-11 02:01:40.267006+0300 dia[964:95858] [default] LaunchServices: store (null) or url (null) was nil: Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=264, _LSFunction=-[_LSDReadClient getServerStoreWithCompletionHandler:]} 2021-12-11 02:01:40.267062+0300 dia[964:95858] [default] Attempt to map database failed: permission was denied. This attempt will not be retried. 2021-12-11 02:01:40.267105+0300 dia[964:95858] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=264, _LSFunction=-[_LSDReadClient getServerStoreWithCompletionHandler:]} 2021-12-11 02:01:40.268634+0300 dia[964:95858] [default] -imageForImageDescriptor: can do IO please adopt -imageForDescriptor: for IO free drawing or -prepareImageForDescriptor: if IO is allowed. (This will become a fault soon.) 2021-12-11 02:01:40.276320+0300 dia[964:95858] Metal API Validation Enabled 2021-12-11 02:01:40.512236+0300 dia[964:95858] [default] LaunchServices: store (null) or url (null) was nil: Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=264, _LSFunction=-[_LSDReadClient getServerStoreWithCompletionHandler:]} 2021-12-11 02:01:40.512331+0300 dia[964:95858] [default] Attempt to map database failed: permission was denied. This attempt will not be retried. 2021-12-11 02:01:40.512396+0300 dia[964:95858] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-54 "process may not map database" UserInfo={NSDebugDescription=process may not map database, _LSLine=264, _LSFunction=-[_LSDReadClient getServerStoreWithCompletionHandler:]} 2021-12-11 02:01:40.512597+0300 dia[964:95858] [default] -imageForImageDescriptor: can do IO please adopt -imageForDescriptor: for IO free drawing or -prepareImageForDescriptor: if IO is allowed. (This will become a fault soon.) 2021-12-11 02:01:40.518850+0300 dia[964:95858] [LayoutConstraints] Changing the translatesAutoresizingMaskIntoConstraints property of a UICollectionReusableView that is managed by a UICollectionView is not supported, and will result in incorrect self-sizing. View: <_UIActivityContentFooterView: 0x1021589b0; baseClass = UICollectionReusableView; frame = (20 482.5; 374 52); layer = <CALayer: 0x28133d660>> My full code: // // export.swift // dia // // Created by Артем on 01.09.2021. // import SwiftUI import UIKit struct export: View {   @State private var isPres: Bool = false   @State private var isLoad: Bool = true   @State private var path: [Any] = []   var anatomy = Anatomy()   var body: some View {     ZStack {       VStack {         ScrollView {           HStack {             Button(action:{               isLoad.toggle()               Task {                 path.removeAll()                 path.append(try await anatomy.generate())                 DispatchQueue.main.asyncAfter(deadline: .now() + 0.20) {                   isLoad.toggle()                 }               }               isPres.toggle()             }){               VStack{                 Image("menu_xlsx")                 Text("Показать данные в \n таблице").foregroundColor(Color.black).multilineTextAlignment(.center)               }             }             .sheet(isPresented: $isPres) {               ShareSheet(activityItems: path)             }             Button(action:{}){               VStack{                 Image("menu_mail")                 Text("Отправить данные \n врачу").foregroundColor(Color.black).multilineTextAlignment(.center)               }             }           }.padding(.top)         }         Spacer()       }       if !isLoad {         ProgressView()           .progressViewStyle(.circular)           .scaleEffect(2.5)       }     }     .navigationBarTitle("Экспорт данных")   } } struct ShareSheet: UIViewControllerRepresentable { //  typealias Callback = (_ activityType: UIActivity.ActivityType?, _ completed: Bool, _ returnedItems: [Any]?, _ error: Error?) -> Void   let activityItems: [Any]   let applicationActivities: [UIActivity]? = nil //  let excludedActivityTypes: [UIActivity.ActivityType]? = nil //  let callback: Callback? = nil       func makeUIViewController(context: Self.Context) -> UIActivityViewController {     let controller = UIActivityViewController(       activityItems: activityItems,       applicationActivities: applicationActivities) //    controller.excludedActivityTypes = excludedActivityTypes //    controller.completionWithItemsHandler = callback     return controller   }       func updateUIViewController(_ uiViewController: UIActivityViewController, context: Self.Context) {     // nothing to do here   } } struct export_Previews: PreviewProvider {   static var previews: some View {     export()   } }
1
0
1.2k
Dec ’21
Asynchronous loading is slowing down
I have a page consisting of a search box and a list. By default, the list consists of many food categories. If the user starts entering the name of the dish in the search bar, the sheet should be cleared and filled with a new list of products. I want to make the input to the search bar and the product search process itself work asynchronously, because this is a rather slow procedure. In the code below, I tried to implement an asynchronous loading mechanism, but in fact the list loads just as slowly, if not worse. Can someone help me to sort out this issue?     var body: some View {         NavigationView{         ZStack {             ScrollView {                 VStack(alignment: .leading, spacing: 0){                     Divider()                     TextField("Поиск по слову", text: $selectedFood)                         .padding(.vertical, 10)                         .onChange(of: selectedFood, perform: {selectedFood in                             if !selectedFood.isEmpty {                                 Task {                                     FoodList = try await GetFoodItemsByName(_name: selectedFood)                                     searchByWordView = false                                 }                             } else {                                 Task{                                     FoodList = try await FillFoodCategoryList()                                     searchByWordView = true                                 }                             }                         })                     Divider()                     ForEach(FoodList){dish in                         if !searchByWordView {                             DoButton(dish: dish)                             Divider()                         } else {                             DoLink(dish: dish)                             Divider()                         }                     }                 }.padding(.leading, 20)             }             .task {                 Task{                     FoodList = try await FillFoodCategoryList()                 }             }             .listStyle(.plain)             if !addScreen {                 addSreenView(addScreen: $addScreen, gram: $gram, selectedFood: $selectedFoodTemp, foodItems: $foodItems)             }         }         .navigationTitle("Добавить блюдо")         .navigationBarTitleDisplayMode(.large)         .interactiveDismissDisabled()         }     }
0
0
427
Nov ’21