Discuss the different user interface frameworks available for your app.

All subtopics
Posts under UI Frameworks topic

Post

Replies

Boosts

Views

Activity

PHPickerViewController - can't get URL from PHPickerResult
Hi, I have a little issue with this new API PHPPickerViewController:  var configuration = PHPickerConfiguration()  configuration.filter = .any(of: [.images])  configuration.selectionLimit = 10  configuration.preferredAssetRepresentationMode = .compatible let picker = PHPickerViewController(configuration: configuration)  picker.delegate = self  present(picker, animated: true, completion: nil) func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {   var selectedPhotosData : [Data] = []   for (index,result) in results.enumerated() { 				 result.itemProvider.loadFileRepresentation(forTypeIdentifier: "public.jpeg") { (url, error) in     guard let fileUrl = url else {return } print(fileUrl)      } } This code above doesn't work, I don't get the URL at all. I tried on Simulator and real device but the same problem. I tried loadObject function but I can't the UIImages... I saw some workarounds here but they don't work in my case it seems...
3
0
4.1k
Feb ’22
UISplitViewController - showDetailViewController(_ vc: UIViewController, sender: Any?) stacking view controllers.
Using UISplitViewController for displaying contact list and contact details screen. Primary, I have UITableViewController. On didSelectRow: set segue/programatically handle delegate to call showDetailViewControler. it always pushes viewController. Question is instead of replacing secondary why need to push. Most of solution I found that hide back button and keep on push and increasing navigation stack. Print this self.viewController(for: .secondary)?.navigationController?.viewControllers.count on segue/didSelectRow delegate. count keeps on increasing.
0
0
1k
Feb ’22
How do I get a tab bar in iOS15 that looks like the one in iOS14?
I don't understand the changes made to the tab bar in iOS 15. In my app, I have a collection view that goes all the way down to the bottom of the screen. When the tab bar appears, it covers some of that collection view, which is fine. However, in iOS15, the tab bar has no background (and no blur effect), thus making the tab bar item text hard to see over the collection view. In interface builder, I tried turning on the "Scroll Edge" option. This gives a translucent background to the tab bar similar to what I had in iOS 14. Unfortunately, the menu tab bar item text size is affected by this option. For some reason, it doesn't use the font size I set, but something smaller. Why is this happening? How do I get it to use the correct font size? P.S. I'm only using text for the tab bar items. There are no images.
11
0
16k
Feb ’22
How to implement the right detail panel by swiftUI?
The video wwdc21-10062 claimed that by using swiftUI developers can build an app with a detail panel (like the right sidebar in Xcode), but didn't say how to implement that. I have tried to use HSplitView but failed. My code is like: var body: some View { NavigationView { Text("sidebar") HSplitView { Text("Primary View") Text("Detail Panel") } } }
3
0
2.2k
Feb ’22
Custom attribute for CSSearchableItemAttributeSet seems not working
In the document it says you can define your own custom attribute: The attributes you choose depend on your domain. You can use the properties that Core Spotlight provides in categories that CSSearchableItemAttributeSet defines (such as Media and Documents), or you can define your own. If you want to define a custom attribute, be as specific as possible in your definition and use the contentTypeTree property so that your custom attribute can inherit from a known type. I tried to index a custom attribute with the following code: class mySpotlightDelegate:NSCoreDataCoreSpotlightDelegate { static let myCustomAttr = CSCustomAttributeKey(keyName: "myCustomAttr")! override func attributeSet(for object: NSManagedObject) -> CSSearchableItemAttributeSet? { if let myObject = object as? MyObject { let attributeSet = CSSearchableItemAttributeSet(contentType: .bookmark) attributeSet.title = myObject.name attributeSet.setValue( NSString(string: myObject.myAttr), forCustomKey: mySpotlightDelegate.myCustomAttr ) return attributeSet } return nil } } But later I couldn't either search with the custom attribute nor get the value of that custom attribute in the CSSearchQuery foundItemsHandler. (The search returns nil and when searched with title it was fine, but when I tried to get the value of custom attribute of returned items with item.attributeSet.value(forCustomKey: mySpotlightDelegate.myCustomAttr), the value is always nil) I've read through all official document regarding this and also searched everywhere but can't find an example of this anywhere, execept 2 other developers complaining about this problem. Is this a bug, or I'm doing it wrong? What's the right way to do it?
0
0
1k
Feb ’22
Xcode module's paths bug
Hello everyone, I faced with a problem: when I try to use Firebase and FirebaseFirestoreSwift (installed via Xcode Package Manager, latest version) for Codable, - I got error for this part of code: documents.compactMap({ QueryDocumentSnapshot -> User? in   return try? QueryDocumentSnapshot.data(as: User.self) }) Value of type 'NSObject' has no member 'data' By the way, I used official docs to import Firebase and FirebaseFirestoreSwift import Foundation import Firebase import FirebaseFirestoreSwift I tried to build my code via another IDEA (AppCode) - and it built it perfectly without any error. When I tried to clear build cache I was getting next error: No such module 'FirebaseFirestoreSwift' But it is installed! Please, help me to fix this issue Maybe I am doing something wrong Thank you all in advance
1
0
808
Jan ’22
Trouble with WWDC21 sample code for CloudKit
Hey all, I've just taken Xcode 13 Beta 2, and I still can't get the sample code from the "Sharing-Data" code to work properly, and nor does the boilerplate code from creating a new project that incorporates CodeData and CloudKit work. Fo far my feedback items have not been identified as having other similar issues - based on the posts I'm seeing I'm not the only one experiencing the same problem. Has anyone got this code built and working yet? Mine breaks when you try to copy the sharing link.
4
0
1.8k
Jan ’22
Keyboard shortcuts for standard iPadOS 15 keyboard shortcuts
My iPad app supports features such Copy (cmd-C) and Paste (cmd-V). How can I get these to show in the Edit menu when I hold down the Command key? Undo (cmd-Z) and Redo (shift-cmd-Z) show perfectly. Looks like the system internally looks at UndoManager. Same with Hide Sidebar: system detected presence of Sidebar and is showing the keyboard shortcut to hide it. Ramon.
1
0
1.2k
Jan ’22
iOS 15 simulator vs. Cloudkit sharing invites
I am running the WWDC21 sample application "CoreDataCloudkitDemo" with two different Apple IDs to test the Cloudkit sharing feature. I use two simulators and one real device, where the latter has the same ID as one of the simulators. While creating invites via "Copy link" works on all three installations, accepting invites only works on the real device. Trying to open an invite (by copying the link in the one and pasting it into Safari in the other) always results in a web page stating that "iCloud has stopped responding" and "Unable to find applicationIdentifier for the containerId = [my ID] and fileExtension = undefined". Is this a simulator bug in Xcode 13.2 or is there anything I can do about it? Other iCloud features (including login via Safari to icloud.com) work in both simulators. Is there a way to open invite URLs in a simulator (as there is no functioning iMessage or Mail app) other than Safari's URL input field? Doing so does not work in the real device either, but clicking it in e.g. iMessage works. Edit: Pasting the link into a ToDo item and opening it from there works even in the simulator - so is it just a Safari issue?
0
0
1.4k
Jan ’22
handle never invoked with WKURLSessionRefreshBackgroundTask type
Hi Folks, I am building a SwiftUI based WatchOS app primarily focused on updating a complication using data from a REST API call. I am trying to reproduce the approach to updating complications in the background as described in "Keeping your complications up to date". The trouble I have is that the func handle(_ backgroundTasks: Set<WKRefreshBackgroundTask>) method on the ExtensionDelegate is never called for the WKURLSessionRefreshBackgroundTask task type. The handle method is invoked for other task types such as WKSnapshotRefreshBackgroundTask. After some refactoring, I have deviated from the approach in the video and I now reshedule the background task in the func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) method of the URLSessionDownloadDelegate. This works fine, and the tasks are being resheduled in the background, but my concern is that there maybe a WKURLSessionRefreshBackgroundTask object lurking in the background for which I haven't called setTaskCompletedWithSnapshot. My session is configured as follows: private lazy var backgroundURLSession: URLSession = { let appBundleName = Bundle.main.bundleURL.lastPathComponent.lowercased().replacingOccurrences(of: " ", with: ".") let sessionIdentifier = "com.gjam.liffeywatch.\(appBundleName)" let config = URLSessionConfiguration .background(withIdentifier: sessionIdentifier) config.isDiscretionary = false config.sessionSendsLaunchEvents = true config.requestCachePolicy = .reloadIgnoringLocalCacheData config.urlCache = nil return URLSession (configuration: config, delegate: self , delegateQueue: nil ) }() and the scheduling code is a follows: func schedule(_ first: Bool) { print("Scheduling background URL session") let bgTask = backgroundURLSession.downloadTask(with: LiffyDataProvider.url) #if DEBUG bgTask.earliestBeginDate = Date().addingTimeInterval(first ? 10 : 60 * 2) #else bgTask.earliestBeginDate = Date().addingTimeInterval(first ? 30 : 60 * 60 * 2) #endif bgTask.countOfBytesClientExpectsToSend = 200 bgTask.countOfBytesClientExpectsToReceive = 1024 bgTask.resume() print("Task started") backgroundTask = bgTask } Does anyone have any idea's why the handle method is not invoked with WKURLSessionRefreshBackgroundTask tasks? Cheers, Gareth.
2
0
1.3k
Jan ’22
@MainActor and the guarantee that the properties are only ever accessed from the main actor
In https://developer.apple.com/videos/play/wwdc2021-10019/?time=815 was said: "By adding the new @MainActor annotation to Photos, the compiler will guarantee that the properties (...) are only ever accessed from the main actor." What does it exactly mean? Let's consider the following example: @MainActor class ViewModel: ObservableObject {   @Published var text = "" } struct ContentView: View {   @StateObject private var viewModel = ViewModel()   var body: some View {     VStack {       Text(viewModel.text)         .padding()       Button("Refresh") {         Task.detached {           await updateText()         }       }     }   }   func updateText() async {     viewModel.text = "Hello, world"   } } Compiler doesn't complain. After button tap viewModel.text is changed from background actor and there is runtime warning: "Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates." So once again: How exactly @MainActor annotation and the compiler will guarantee that the properties are only ever accessed from the main actor?
0
0
1.4k
Jan ’22
Inset grouped table cells not aligned with large title
Hi, It seems that when using the inset grouped style in a UITableView, the cells are not aligned with the navigation bar large title. However, I've noticed that all Apple apps that seem to use this style (Settings, Notes) don't have this issue and the cells are perfectly aligned with the title. In the below example you can see that the cells of an inset grouped table are not aligned with the title (extra space between the red line and the cells) but the one's of the Apple apps are perfectly aligned. Do you know if there is a way to change the left and right cells margins of an inset grouped table in order to align them with the large title? Thank you
4
0
4.1k
Jan ’22
PHPickerViewController - can't get URL from PHPickerResult
Hi, I have a little issue with this new API PHPPickerViewController:  var configuration = PHPickerConfiguration()  configuration.filter = .any(of: [.images])  configuration.selectionLimit = 10  configuration.preferredAssetRepresentationMode = .compatible let picker = PHPickerViewController(configuration: configuration)  picker.delegate = self  present(picker, animated: true, completion: nil) func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {   var selectedPhotosData : [Data] = []   for (index,result) in results.enumerated() { &#9;&#9;&#9;&#9; result.itemProvider.loadFileRepresentation(forTypeIdentifier: "public.jpeg") { (url, error) in     guard let fileUrl = url else {return } print(fileUrl)      } } This code above doesn't work, I don't get the URL at all. I tried on Simulator and real device but the same problem. I tried loadObject function but I can't the UIImages... I saw some workarounds here but they don't work in my case it seems...
Replies
3
Boosts
0
Views
4.1k
Activity
Feb ’22
UISplitViewController - showDetailViewController(_ vc: UIViewController, sender: Any?) stacking view controllers.
Using UISplitViewController for displaying contact list and contact details screen. Primary, I have UITableViewController. On didSelectRow: set segue/programatically handle delegate to call showDetailViewControler. it always pushes viewController. Question is instead of replacing secondary why need to push. Most of solution I found that hide back button and keep on push and increasing navigation stack. Print this self.viewController(for: .secondary)?.navigationController?.viewControllers.count on segue/didSelectRow delegate. count keeps on increasing.
Replies
0
Boosts
0
Views
1k
Activity
Feb ’22
How do I get a tab bar in iOS15 that looks like the one in iOS14?
I don't understand the changes made to the tab bar in iOS 15. In my app, I have a collection view that goes all the way down to the bottom of the screen. When the tab bar appears, it covers some of that collection view, which is fine. However, in iOS15, the tab bar has no background (and no blur effect), thus making the tab bar item text hard to see over the collection view. In interface builder, I tried turning on the "Scroll Edge" option. This gives a translucent background to the tab bar similar to what I had in iOS 14. Unfortunately, the menu tab bar item text size is affected by this option. For some reason, it doesn't use the font size I set, but something smaller. Why is this happening? How do I get it to use the correct font size? P.S. I'm only using text for the tab bar items. There are no images.
Replies
11
Boosts
0
Views
16k
Activity
Feb ’22
How to implement the right detail panel by swiftUI?
The video wwdc21-10062 claimed that by using swiftUI developers can build an app with a detail panel (like the right sidebar in Xcode), but didn't say how to implement that. I have tried to use HSplitView but failed. My code is like: var body: some View { NavigationView { Text("sidebar") HSplitView { Text("Primary View") Text("Detail Panel") } } }
Replies
3
Boosts
0
Views
2.2k
Activity
Feb ’22
Custom attribute for CSSearchableItemAttributeSet seems not working
In the document it says you can define your own custom attribute: The attributes you choose depend on your domain. You can use the properties that Core Spotlight provides in categories that CSSearchableItemAttributeSet defines (such as Media and Documents), or you can define your own. If you want to define a custom attribute, be as specific as possible in your definition and use the contentTypeTree property so that your custom attribute can inherit from a known type. I tried to index a custom attribute with the following code: class mySpotlightDelegate:NSCoreDataCoreSpotlightDelegate { static let myCustomAttr = CSCustomAttributeKey(keyName: "myCustomAttr")! override func attributeSet(for object: NSManagedObject) -> CSSearchableItemAttributeSet? { if let myObject = object as? MyObject { let attributeSet = CSSearchableItemAttributeSet(contentType: .bookmark) attributeSet.title = myObject.name attributeSet.setValue( NSString(string: myObject.myAttr), forCustomKey: mySpotlightDelegate.myCustomAttr ) return attributeSet } return nil } } But later I couldn't either search with the custom attribute nor get the value of that custom attribute in the CSSearchQuery foundItemsHandler. (The search returns nil and when searched with title it was fine, but when I tried to get the value of custom attribute of returned items with item.attributeSet.value(forCustomKey: mySpotlightDelegate.myCustomAttr), the value is always nil) I've read through all official document regarding this and also searched everywhere but can't find an example of this anywhere, execept 2 other developers complaining about this problem. Is this a bug, or I'm doing it wrong? What's the right way to do it?
Replies
0
Boosts
0
Views
1k
Activity
Feb ’22
Xcode module's paths bug
Hello everyone, I faced with a problem: when I try to use Firebase and FirebaseFirestoreSwift (installed via Xcode Package Manager, latest version) for Codable, - I got error for this part of code: documents.compactMap({ QueryDocumentSnapshot -> User? in   return try? QueryDocumentSnapshot.data(as: User.self) }) Value of type 'NSObject' has no member 'data' By the way, I used official docs to import Firebase and FirebaseFirestoreSwift import Foundation import Firebase import FirebaseFirestoreSwift I tried to build my code via another IDEA (AppCode) - and it built it perfectly without any error. When I tried to clear build cache I was getting next error: No such module 'FirebaseFirestoreSwift' But it is installed! Please, help me to fix this issue Maybe I am doing something wrong Thank you all in advance
Replies
1
Boosts
0
Views
808
Activity
Jan ’22
Trouble with WWDC21 sample code for CloudKit
Hey all, I've just taken Xcode 13 Beta 2, and I still can't get the sample code from the "Sharing-Data" code to work properly, and nor does the boilerplate code from creating a new project that incorporates CodeData and CloudKit work. Fo far my feedback items have not been identified as having other similar issues - based on the posts I'm seeing I'm not the only one experiencing the same problem. Has anyone got this code built and working yet? Mine breaks when you try to copy the sharing link.
Replies
4
Boosts
0
Views
1.8k
Activity
Jan ’22
Keyboard shortcuts for standard iPadOS 15 keyboard shortcuts
My iPad app supports features such Copy (cmd-C) and Paste (cmd-V). How can I get these to show in the Edit menu when I hold down the Command key? Undo (cmd-Z) and Redo (shift-cmd-Z) show perfectly. Looks like the system internally looks at UndoManager. Same with Hide Sidebar: system detected presence of Sidebar and is showing the keyboard shortcut to hide it. Ramon.
Replies
1
Boosts
0
Views
1.2k
Activity
Jan ’22
iOS 15 simulator vs. Cloudkit sharing invites
I am running the WWDC21 sample application "CoreDataCloudkitDemo" with two different Apple IDs to test the Cloudkit sharing feature. I use two simulators and one real device, where the latter has the same ID as one of the simulators. While creating invites via "Copy link" works on all three installations, accepting invites only works on the real device. Trying to open an invite (by copying the link in the one and pasting it into Safari in the other) always results in a web page stating that "iCloud has stopped responding" and "Unable to find applicationIdentifier for the containerId = [my ID] and fileExtension = undefined". Is this a simulator bug in Xcode 13.2 or is there anything I can do about it? Other iCloud features (including login via Safari to icloud.com) work in both simulators. Is there a way to open invite URLs in a simulator (as there is no functioning iMessage or Mail app) other than Safari's URL input field? Doing so does not work in the real device either, but clicking it in e.g. iMessage works. Edit: Pasting the link into a ToDo item and opening it from there works even in the simulator - so is it just a Safari issue?
Replies
0
Boosts
0
Views
1.4k
Activity
Jan ’22
handle never invoked with WKURLSessionRefreshBackgroundTask type
Hi Folks, I am building a SwiftUI based WatchOS app primarily focused on updating a complication using data from a REST API call. I am trying to reproduce the approach to updating complications in the background as described in "Keeping your complications up to date". The trouble I have is that the func handle(_ backgroundTasks: Set<WKRefreshBackgroundTask>) method on the ExtensionDelegate is never called for the WKURLSessionRefreshBackgroundTask task type. The handle method is invoked for other task types such as WKSnapshotRefreshBackgroundTask. After some refactoring, I have deviated from the approach in the video and I now reshedule the background task in the func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) method of the URLSessionDownloadDelegate. This works fine, and the tasks are being resheduled in the background, but my concern is that there maybe a WKURLSessionRefreshBackgroundTask object lurking in the background for which I haven't called setTaskCompletedWithSnapshot. My session is configured as follows: private lazy var backgroundURLSession: URLSession = { let appBundleName = Bundle.main.bundleURL.lastPathComponent.lowercased().replacingOccurrences(of: " ", with: ".") let sessionIdentifier = "com.gjam.liffeywatch.\(appBundleName)" let config = URLSessionConfiguration .background(withIdentifier: sessionIdentifier) config.isDiscretionary = false config.sessionSendsLaunchEvents = true config.requestCachePolicy = .reloadIgnoringLocalCacheData config.urlCache = nil return URLSession (configuration: config, delegate: self , delegateQueue: nil ) }() and the scheduling code is a follows: func schedule(_ first: Bool) { print("Scheduling background URL session") let bgTask = backgroundURLSession.downloadTask(with: LiffyDataProvider.url) #if DEBUG bgTask.earliestBeginDate = Date().addingTimeInterval(first ? 10 : 60 * 2) #else bgTask.earliestBeginDate = Date().addingTimeInterval(first ? 30 : 60 * 60 * 2) #endif bgTask.countOfBytesClientExpectsToSend = 200 bgTask.countOfBytesClientExpectsToReceive = 1024 bgTask.resume() print("Task started") backgroundTask = bgTask } Does anyone have any idea's why the handle method is not invoked with WKURLSessionRefreshBackgroundTask tasks? Cheers, Gareth.
Replies
2
Boosts
0
Views
1.3k
Activity
Jan ’22
@MainActor and the guarantee that the properties are only ever accessed from the main actor
In https://developer.apple.com/videos/play/wwdc2021-10019/?time=815 was said: "By adding the new @MainActor annotation to Photos, the compiler will guarantee that the properties (...) are only ever accessed from the main actor." What does it exactly mean? Let's consider the following example: @MainActor class ViewModel: ObservableObject {   @Published var text = "" } struct ContentView: View {   @StateObject private var viewModel = ViewModel()   var body: some View {     VStack {       Text(viewModel.text)         .padding()       Button("Refresh") {         Task.detached {           await updateText()         }       }     }   }   func updateText() async {     viewModel.text = "Hello, world"   } } Compiler doesn't complain. After button tap viewModel.text is changed from background actor and there is runtime warning: "Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates." So once again: How exactly @MainActor annotation and the compiler will guarantee that the properties are only ever accessed from the main actor?
Replies
0
Boosts
0
Views
1.4k
Activity
Jan ’22
Inset grouped table cells not aligned with large title
Hi, It seems that when using the inset grouped style in a UITableView, the cells are not aligned with the navigation bar large title. However, I've noticed that all Apple apps that seem to use this style (Settings, Notes) don't have this issue and the cells are perfectly aligned with the title. In the below example you can see that the cells of an inset grouped table are not aligned with the title (extra space between the red line and the cells) but the one's of the Apple apps are perfectly aligned. Do you know if there is a way to change the left and right cells margins of an inset grouped table in order to align them with the large title? Thank you
Replies
4
Boosts
0
Views
4.1k
Activity
Jan ’22