UI Frameworks

RSS for tag

Discuss the different user interface frameworks available for your app.

Posts under UI Frameworks tag

29 Posts
Sort by:
Post not yet marked as solved
2 Replies
2.0k Views
Hi, the video was great and on point, but it only featured UIKit apis. 3 years into the SwiftUI transition, I wonder if this is a UIKit only feature or can we also use it if we chose SwiftUI to build our apps ? Thanks
Posted
by mbritto.
Last updated
.
Post marked as solved
1 Replies
870 Views
I've been trying to disable the "Smart Selection" feature introduced in https://developer.apple.com/wwdc20/10107 from a PKCanvasView. This feature could be very useful for some apps but if you want to start from a clean state canvas it might get in your way as you add gestures and interactions. Is there any way to opt out from it? The #WWDC20-10107 video demonstrates the "Smart Selection" feature at around 1:27.
Posted
by Juan.
Last updated
.
Post not yet marked as solved
1 Replies
1.3k Views
I am trying to implement Quick Notes through SwiftUI, rather than UIKit or AppKit. I am unsure if the behaviour below is expected, or due to a bug. I have already successfully implemented NSUserActivity for Handoff, Spotlight and Siri Reminders, using the .userActivity() view modifier. These NSUserActivity instances use the NSUserActivity.userInfo dictionary to store and correctly restore the content through the .onContinueUserActivity(perform: ) methods. Quick Notes requires using the .persistentIdentifier or .targetContentIdentifier properties, rather than the .userInfo dictionary alone. However, when I set these either of these to unique identifiers using the code below, they are not correctly stored within the useractivity. MyView() .userActivity(ActivityString, updateUserActivity) private func updateUserActivity(_ activity: NSUserActivity) {     activity.isEligibleForSearch = true     activity.isEligibleForHandoff = true     activity.title = "Title"     activity.targetContentIdentifier = myItemUniqueID     activity.persistentIdentifier = myItemUniqueID     activity.userInfo = ["id": myItemUniqueID]     print(activity.targetContentIdentifier) // Correctly prints     print(activity.persistentIdentifier) // Correctly prints     print(activity.userInfo) // Correctly prints     } The identifiers print correctly when setting the user activity above. However, when restoring the user activity (tested through Handoff and Spotlight Search), the targetContentIdentifier and persistentIdentifier strings are empty. MyView()     .onContinueUserActivity(ActivityString, perform: continueUserActivity) private func continueUserActivity(_ activity: NSUserActivity) {     print(activity.persistentIdentifier) // Nil     print(activity.targetContentIdentifier) // Nil     print(activity.userInfo) // Correctly prints     } Is there something else I must do, or is this unexpected behaviour?
Posted Last updated
.
Post not yet marked as solved
0 Replies
625 Views
I've been trying to save a selected color with UserDefaults from UIColorPickerViewController. But I run into a color space fiasco. Anyway, here come my lines of code. class ViewController: UIViewController, UIColorPickerViewControllerDelegate { @IBOutlet weak var imageView: UIImageView! @IBAction func selectTapped(_ sender: UIButton) { let picker = UIColorPickerViewController() picker.delegate = self picker.selectedColor = .yellow picker.supportsAlpha = false present(picker, animated: true, completion: nil) } override func viewDidLoad() { super.viewDidLoad() } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) if let color = UserDefaultsUIColor.shared.readColor(key: "MyColor") { print("Color being read: \(color)") } } func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) { let color = viewController.selectedColor print("Selected color: \(color)") UserDefaultsUIColor.shared.saveColor(color: viewController.selectedColor, key: "MyColor") } func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) { imageView.backgroundColor = viewController.selectedColor } } class UserDefaultsUIColor { static let shared = UserDefaultsUIColor() func saveColor(color: UIColor, key: String) { let userDefaults = UserDefaults.standard do { let data = try NSKeyedArchiver.archivedData(withRootObject: color, requiringSecureCoding: false) as NSData? userDefaults.set(data, forKey: key) } catch { print("Error UserDefaults: \(error.localizedDescription)") } } func readColor(key: String) -> UIColor? { let userDefaults = UserDefaults.standard if let data = userDefaults.data(forKey: key) { do { if let color = try NSKeyedUnarchiver.unarchivedObject(ofClass: UIColor.self, from: data) { return color } } catch { print("Error UserDefaults") } } return nil } } I first start out with a yellow color (UIColor.yellow). And I select a color whose RGB values are 76, 212, 158, respectively. And the color picker guy returns the following. kCGColorSpaceModelRGB 0.298039 0.831373 0.619608 1 And I get the following in reading the saved color data object. UIExtendedSRGBColorSpace -0.270778 0.84506 0.603229 1 How can I save and read color data objects consistently? I could specify a color space when I save a color. But it doesn't go well. Muchos thankos Señor Tomato de Source
Posted
by Tomato.
Last updated
.
Post not yet marked as solved
1 Replies
780 Views
I know this is far after the fact, but in going through the Widgets Code-along, part 2: Alternate timelines code-along, and having done very little SwiftUI, I ran into an issue that I can't seem to figure out. Things like this are one of the biggest reasons I haven't even considered migrating any of my apps to SwiftUI - I just can't get the UI to look the way I want it to. The code in question is very simple: Just a couple of things inside an HStack. For some reason, they added a ZStack around that (the HStack is the only thing inside it), and that ZStack changes the font size of one of the two HStack contents very slightly. For some reason. I'm really not sure why they bothered with the ZStack - it only has one thing inside it. Anyway, the code looks like this: HStack(alignment: .top) { AvatarView(entry.character) .foregroundColor(.white) Text(entry.character.bio) .padding() .foregroundColor(.white) } .padding() .widgetURL(entry.character.url) } .background(Color.gameBackground) .widgetURL(entry.character.url) And on the Panda hero (the only one Izzy demos), it looks fine. But The problem is with literally any other hero - they all have bios that are longer than Panda's, and they all clip their contents. If I put a background or a border on the Text(), it's very clear that while the left side (the AvatarView) takes up the whole height of the widget, the Text does not. That makes sense if its contents are small, but in most cases, the contents are substantially larger, and they clip, while leaving a bunch of blank space underneath. Obviously, that's just simply unacceptable from a UI perspective, and I haven't been able to figure out which of the modifiers I can put on Text will correct this - if any. I'm excited about the potential of SwiftUI to simplify what can often be huge storyboards, but things like this (******, little, should-be-easy things being effectively impossible) make me think that it's not worth the hassle. I did do web searches, including looking on StackOverflow, but what do you even search on for things like this? The terms I searched on, at least, bore no fruit. Thanks in advance for any help you can offer.
Posted Last updated
.
Post not yet marked as solved
0 Replies
821 Views
Hi everyone i have an app that has some related entities. throught the different type of tutorial i see that apple incourages to use relationship and inverse relationship in the core data model, and that what i have done. Now, when i reach the point that a user wants to share one particular entity to other users, the inverse relationship spread the share to all the graph of core database shouldn't the inverse relationship be ignored by the share process? if i want to share only that record and the child, not the parent one, should i break the realtionship with the parent (that for me is the inverse relationship) imposing it to a nil value?
Posted
by TheFinal.
Last updated
.
Post not yet marked as solved
0 Replies
895 Views
I'm specifically talking about macOS because the others are very different beasts. Since, well literally the first release of OS X 10.0, there has not been a coherent automation framework on the Mac. The last OS to offer that was Mac OS 9.X To define terms, by coherent, I mean from the command line environment up through the user interface. A single, coherent automation framework that is usable across the entire OS, ala PowerShell on windows. That doesn't exist for current macOS, nor has it ever existed for any variant of macOS since again, Mac OS 9.X At best it has been a pastiche of completely different frameworks, operating modalities and languages all desperately trying to work together via osascript and do shell script. That any of it works at all is like a talking dog: the fact the dog talks is a miracle, bad grammar is minor. Yes, I know Shortcuts exist, but shortcuts are a developer managed bit of pseudo-automation. If I limit myself to Shortcuts, then I have little to no ability to do anything beyond what the developer of that application chooses to allow me to do. For example, at least as of Ventura, Dictionary, Font Book, iMovie and others have no shortcuts. I can't create my own shortcut for those apps, the devs have to do that. (the fact that Apple is not flooding us with Shortcuts shows how little Apple cares as a company about this. Individual teams wax good and bad, but clearly, Apple doesn't think dogfooding here is important.) (Note: if your only comment is to ask why anyone would care about automating , that's absolutely not the point. The idea is to make it possible for everyone, not just developers, to create in ways no one can predict outside of an application's constraints.) "Well, there's always AppleScript/JXA" I will not write down the laughter here, but there is laughter. As of Ventura, there are no less than 32 Apple applications with no scripting dictionary at all, so neither AppleScript/JXA can work. You might be able to use UI scripting, but no guarantee there, and UI scripting is a fragile thing, at best suited to a last resort option. Again, Apple could lead the way, they choose not to. But that's only the UI levels. Below the UI, then there's no coherency at all. You're stuck with shell scripts and whatever a given utility's author chose to allow, and sharing data and information is no better than at the UI level, and neither the command line level nor the UI level know the other exists. The only way to combine the two is again: Do Shell Script Osascript That is not a coherent automation framework. Then of course, there's the lack of documentation. AppleScript has inherited at least the language guide, which is well-written and usable, but the command line level has man pages. Which are the most inconsistent things. Some utilities' man pages are remarkably useful, others don't even have man pages. At all. Other utilities man pages have syntax errors for the command that brings up the help page and that is all the man page does. Ponder the disconnect there: --help provides detailed usage information that is not in the man page. The man page says use ---help which is bad syntax. This seems odd, but why is the --help output not also in the man page? Is that not the purpose of the man page? Man page inconsistencies aside, Apple developer support has only ever barely acknowledged automation/scripting and really never supported it except for accidentally. Even in a language like AppleScriptObjecttiveC, (ASOC) which one can use for real apps in the MAS, the response from DTS for help was "use the mailing list." (not that DTS is that good anyway, I had an issue with CoreWLAN in ventura, and have since been ghosted on any notification that the OS bug that was causing me problems has been fixed. Maybe it has, maybe it hasn't. I can test for it, but why did DTS ghost an actual SwiftUI issue for an app written in Swift? ¯_(ツ)_/¯ This is a solveable problem, Microsoft has solved it in terms of language, documentation and coherency, with PowerShell. Leaving aside architectural issues that make it almost impossible to properly secure windows, the way MS treats PowerShell is the example. Windows as an OS has excellent support for automation, the documentation for PowerShell is amazing, (the documentation for a scripting language is better than Apple's entire developer docs, which is just inexcusable.) The difference between automating either platform is night and day, and in a race with two horses, Apple is a distant fifth. The language syntax here is almost a non-issue. In fact, I think using a "powershell'd" version of Swift would be an excellent idea. Create a simpler version of swift in the way PowerShell is a simpler version of C#. Make it so if you need to call a framework outside of the main automation framework, you can do so with ease, ala PowerShell. For example, PowerShell has no GUI primitives the way AppleScript does, so to create a file choose browser in PowerShell, you instead invoke the correct .NET framework: Add-Type -AssemblyName System.Windows.Forms $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{ InitialDirectory = [Environment]::GetFolderPath('Desktop') } $null = $FileBrowser.ShowDialog() Ironically, you can do this with ASOC, but only for items that have ObjC interfaces, which will be shrinking. Having a coherent automation framework with a primary language that allows people using it to more easily use "full" Swift and its frameworks as needed is a force-multiplier for Apple. It would help people do more with macOS and maybe other platforms depending on implementation, not less. It would not force people to beg the developers of their apps to write Yet Another Shortcut to do this thing that they can't do, (or have to do the dance to convince the dev that their need is worth the trouble), and it would allow people to solve their problems in their own ways for their own needs. But, it requires Apple to care about this at all, and that is where the problem is. This is fixable, Apple has the resources to fix it, what they lack is interest and desire. But creating and fully supporting a proper automation framework would add so much to macOS and the other platforms by extension that there's no logic behind not doing so. Maybe next year. (in the best lol of all, you can't even create an automation tag for a post. sigh.)
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.2k Views
Good day together, I am already in despair, I would like to insert a button in the NavigationBar next to the NavigationBarTitle which also automatically shrinks or enlarges. The whole thing can be seen in the App Store under the menu item "search". There, when the user scrolls down, the search bar and the title is given as .inline but not the user button. I am currently trying to implement the whole thing in SwiftUI and can't find a solution. Is there already a solution for this or if someone has the exact documentation for this case I would be very grateful for it :). thank you very much!
Posted
by Cliplicht.
Last updated
.