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
1 Replies
59 Views
Summary Hello Apple Developers, I've made a custom UITableViewCell that includes a UITextField and UILabel. When I run the simulation the UITableViewCells pop up with the UILabel and the UITextField, but the UITextField isn't clickable so the user can't enter information. Please help me figure out the problem. Thank You! Sampson What I want: What I have: Screenshot Details: As you can see when I tap on the cell the UITextField isn't selected. I even added placeholder text to the UITextField to see if I am selecting the UITextField and the keyboard just isn't popping up, but still nothing. Relevant Code: UHTextField import UIKit class UHTextField: UITextField { override init(frame: CGRect) { super.init(frame: frame) configure() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } convenience init(placeholder: String) { self.init(frame: .zero) self.placeholder = placeholder } private func configure() { translatesAutoresizingMaskIntoConstraints = false borderStyle = .none textColor = .label tintColor = .blue textAlignment = .left font = UIFont.preferredFont(forTextStyle: .body) adjustsFontSizeToFitWidth = true minimumFontSize = 12 backgroundColor = .tertiarySystemBackground autocorrectionType = .no } } UHTableTextFieldCell import UIKit class UHTableTextFieldCell: UITableViewCell, UITextFieldDelegate { static let reuseID = "TextFieldCell" let titleLabel = UHTitleLabel(textAlignment: .center, fontSize: 16, textColor: .label) let tableTextField = UHTextField() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) configure() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } func set(title: String) { titleLabel.text = title tableTextField.placeholder = "Enter " + title } private func configure() { addSubviews(titleLabel, tableTextField) let padding: CGFloat = 12 NSLayoutConstraint.activate([ titleLabel.centerYAnchor.constraint(equalTo: centerYAnchor), titleLabel.leadingAnchor.constraint(equalTo: leadingAnchor, constant: padding), titleLabel.heightAnchor.constraint(equalToConstant: 20), titleLabel.widthAnchor.constraint(equalToConstant: 80), tableTextField.centerYAnchor.constraint(equalTo: centerYAnchor), tableTextField.leadingAnchor.constraint(equalTo: titleLabel.trailingAnchor, constant: 24), tableTextField.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -padding), tableTextField.heightAnchor.constraint(equalToConstant: 20) ]) } } LoginViewController class LoginViewController: UIViewController, UITextFieldDelegate { let tableView = UITableView() let loginTableTitle = ["Username", "Password"] override func viewDidLoad() { super.viewDidLoad() configureTableView() updateUI() createDismissKeyboardTapGesture() } func createDismissKeyboardTapGesture() { // create the tap gesture recognizer let tap = UITapGestureRecognizer(target: self.view, action: #selector(UIView.endEditing)) // add it to the view (Could also add this to an image or anything) view.addGestureRecognizer(tap) } func configureTableView() { view.addSubview(tableView) tableView.layer.borderWidth = 1 tableView.layer.borderColor = UIColor.systemBackground.cgColor tableView.layer.cornerRadius = 10 tableView.clipsToBounds = true tableView.rowHeight = 44 tableView.delegate = self tableView.dataSource = self tableView.translatesAutoresizingMaskIntoConstraints = false tableView.removeExcessCells() NSLayoutConstraint.activate([ tableView.topAnchor.constraint(equalTo: loginTitleLabel.bottomAnchor, constant: padding), tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: padding), tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -padding), tableView.heightAnchor.constraint(equalToConstant: 88) ]) tableView.register(UHTableTextFieldCell.self, forCellReuseIdentifier: UHTableTextFieldCell.reuseID) } func updateUI() { DispatchQueue.main.async { self.tableView.reloadData() self.view.bringSubviewToFront(self.tableView) } } } extension LoginViewController: UITableViewDelegate, UITableViewDataSource{ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 2 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: UHTableTextFieldCell.reuseID, for: indexPath) as! UHTableTextFieldCell let titles = loginTableTitle[indexPath.row] cell.set(title: titles) cell.titleLabel.font = UIFont.systemFont(ofSize: 16, weight: .bold) cell.tableTextField.delegate = self return cell } } Again thank you all so much for your help. If you need more clarification on this let me know.
Posted
by
Post not yet marked as solved
1 Replies
479 Views
I am directed from https://discuss.appium.io/t/create-multiple-instances-of-the-same-app/41266/14?u=lxnm, the context is that Appium max2 driver is implementing the activating of MacOS app using XCTest API methods. There are 2 ways to implement the activating of the app, using app path (calling initWithURL) and bundle id (calling initWithBundleIdentifier). This pull request shows how the XCTest methods are called when using the Mac2 driver, specifically in the file WebDriverAgentMac/WebDriverAgentLib/Routing/FBSession.m. The problem is that I am able to launch my MacOS app(it is a company app) using bundle id, but when I launch the app with app path, I receive XcodeBuild errors: [WebDriverAgentMac] [xcodebuild] XCTExpectFailure: matcher accepted Assertion Failure: Failed to launch com.company.companyApp: You do not have permission to run the application “companyApp”. You don’t have permission. To view or change permissions, select the item in the Finder and choose File > Get Info. (Underlying Error: The operation couldn’t be completed. Operation not permitted) I followed this to enable R+W permissions to all users, but the same error is displayed.
Posted
by
Post not yet marked as solved
2 Replies
537 Views
Customers are reporting after the update to mac OS Sonoma 14.2 bitmap images have a black background! When we run the same application on Sonoma 14.1.1 the bitmap images appear as expected Like I said at the beginning, it happened after upgrading to Sonoma 14.2 so it introduced the issue.
Posted
by
Post not yet marked as solved
0 Replies
1.3k Views
AI in Apple products revolutionizes user experiences, enhancing Siri's intelligence, facial recognition in iPhones, and personalized recommendations through machine learning. This transformative integration underscores Apple's commitment to innovation, elevating device functionality and user engagement to unprecedented levels.
Posted
by
Post not yet marked as solved
1 Replies
462 Views
Hi, One of my developers has upgraded their office Mac to Sonoma. The app we build has a WPF Windows UI layer, GTK for Linux and Cocoa for Mac, the code being written in C#. On Ventura, it builds and works fine. However, since he's upgraded his Mac to Sonoma, all the images on buttons are stretched to take up the whole size of the button, rather than the position stated, with text underneath. I can't share a screenshot here - it's an internal build not for customer or public use. The following mockups demonstrate what we're seeing: Code built on Sonoma Exact same code built on Ventura Any suggestions?
Posted
by
Post not yet marked as solved
0 Replies
514 Views
Currently, there seems to be an all or nothing approach to supporting rotation on iPhone. Either every screen in your UI supports rotation, or none of them do. For a some apps however, that approach won't work. They have a number of screens that don't adapt well to a super letterboxed screen size, and a number of others that would benefit from the additional screen space. Previous discussion on this issue recommends the use of size classes, but this advice fails to recognise that some use cases simply aren't suited to being super letterboxed. Apple's own UI design is tacit acknowledgement of this: For example, the main UI of the Camera app stays fixed in the portrait orientation in the shooting mode, but presents a rotatable modal to review photos and videos. Even Springboard, the home screen of the iPhone, remains locked in the portrait orientation whilst allowing an app to be presented in landscape. Social media and news apps are another example: generally anchored around a portrait newsfeed that doesn't adapt well to extreme letterboxing, but surfacing rich media such as images, videos, charts and other interactive elements that could use the flexibility of landscape presentation. (News app, looking at you.) Is it time to re-visit the rotation characteristics of the phone vs. tablet idioms? Is this all-or-nothing approach to rotation serving the platform well? Regardless, app designers at Apple and elsewhere are creating apps that use this hybrid approach to rotation. And as things stand today, SwiftUI makes it very difficult. A rough equivalent can be made using a ZStack and observing the device orientation, but this requires hiding the status bar and provides no way to honor a user's portrait lock settings. The only other option, as far as I can tell, is building the app using UIKit view controllers, to thread through supportedInterfaceOrientations hooks. Personally, what I'd love to see is a new presentationInterfaceOrientations(_:) hook on View, that allows a fullScreenCover presentation to be specified as supporting an alternative orientation set. This could be iPhone only, and should serve the majority of use cases. However, in the meantime, it would be great to know if there's a technique that can get the UIKit behavior in a SwiftUI app that doesn't require rewriting the entire container view hierachy in UIKit.
Posted
by
Post not yet marked as solved
0 Replies
415 Views
I think I have found a Cocoa memory leak that is resulting in my NSDocuments being retained after they have been closed by the user. I am posting here to see if anyone else has encountered this, and if so, what solutions might be available. Essentially, when you have an Autosaving NSDocument that opens an NSWindow containing an NSToolbar the default 'Unified' toolbar style places the Document title to the left of the Toolbar. When the titlebar is laid out like this, there is a clickable area to the right of the title. If the user clicks in this area a log error appears that reads '[Document] Popover failed to show' This seems harmless enough, but in actual fact a memory leak has occurred with the 'NSDocumentTitlebarPopoverViewController' that has failed to show. This View Controller is retained, and unfortunately it contains a strong reference to the NSDocument. So the entire NSDocument instance is also retained. Here is a screenshot of the clickable area: Here is a link to a minimum reproducible example, hosted on GitHub. It is just a template Document Based App with an added Toolbar and a print statement in the Deinit of the Document so you can see if it deinits successfully. Searching online for the '[Document] Popover failed to show' log message doesn't yield any results, nor does searching for the leaking View Controller class name ('NSDocumentTitlebarPopoverViewController').
Posted
by
Post not yet marked as solved
5 Replies
2.2k Views
After Updating my app to iOS 17.0 I noticed some odd behavior when swiping a detail view away with a parent view that has a toolbar with a ToolbarItem(placement: .bottomBar). As the user starts a leading swipe gesture to navigate back to the previous view the parent navigation title strangely animates to the center and the leading nav bar button disappears. If the user stops this gesture at any point before completing the swipe they will be stuck in the detail view as the leading nav button has disappeared. This only seems to be an issue if one attempts to swipe back to the parent view and not when the leading nav button is tapped. The following is the minimum code to reproduce this issue for me. I am testing on a physical device on iOS 17.0 with Xcode Version 15.0 (15A240d). struct ToolbarIssueView: View { var body: some View { NavigationStack { NavigationLink { Text("Detail View") .navigationTitle("Detail") } label: { Text("To Detail View") } .toolbar { // This seems to cause strange behavior ToolbarItem(placement: .bottomBar) { Text("Bottom Bar Content") } } .navigationTitle("Main") } } } I understand that this bottom bar could easily be replaced with a .safeAreaInset(edges: .bottom) but I would prefer to use the more standard ToolbarItem(placement: .bottomBar). If anyone has any fixes for this issue or know what I am missing I would love to hear it!
Posted
by
Post not yet marked as solved
0 Replies
442 Views
I'm trying to understand the mechanism by which the Quit Application menu item gets disabled while a modal dialog/alert is up. Who is responsible for disabling the menu item? We have a case where in some cases, the Quit Application menu item is not getting disabled even when a modal dialog is up. So I'm trying to figure out where things may be going wrong.
Posted
by
Post not yet marked as solved
2 Replies
713 Views
I keep getting random crashes, when attempting to reconfigure an existing item. I check immediately for that if the item identifier exists in the data source and do not attempt to configure it if it's not. This is there error message: "Attempted to reconfigure item identifier that does not exist in the snapshot: ..." Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation 0x9cb4 __exceptionPreprocess 1 libobjc.A.dylib 0x183d0 objc_exception_throw 2 Foundation 0x4e154c _userInfoForFileAndLine 3 UIKitCore 0xa44a8 -[__UIDiffableDataSourceSnapshot _validateReloadUpdateThrowingIfNeeded:] 4 UIKitCore 0xa2ed8 -[__UIDiffableDataSourceSnapshot _commitUpdateAtomic:] 5 UIKitCore 0x561048 -[__UIDiffableDataSourceSnapshot reconfigureItemsWithIdentifiers:] 6 libswiftUIKit.dylib 0x35d0c NSDiffableDataSourceSnapshot.deleteItems(_:) 7 Trulia 0x45380c closure #1 in ActivityFeedV3ViewController.updateUI(for:) 8 Trulia 0x4c4f58 thunk for @escaping @callee_guaranteed () -> () (<compiler-generated>)
Posted
by
Post not yet marked as solved
0 Replies
459 Views
Yes, I know WWDC21 was a long time ago but here it is August 2023 and I am looking at the "Building a Great App with SwiftUI. Following along with the Session 1 and 2 videos, I get to the part where you add an Export command. Only, the Export dialog does not appear. The "completed" session 2 source also fails to display an Export dialog. In fact there appears to be no definition for an Export view. I've searched the web, including the Apple forum, for this problem but it looks like no one has encountered this bug. Did anyone ever get this Great App to work?
Posted
by
Post not yet marked as solved
0 Replies
623 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
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
by
Post marked as solved
1 Replies
868 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
Post not yet marked as solved
0 Replies
820 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
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
by
Post marked as solved
3 Replies
2.1k Views
I have a full screen list and want to use the new keyboardLayoutGuide constraint, but by default it uses the safe area inset. How can I disable this so my list goes all the way to the bottom of the screen when the keyboard is not shown? NSLayoutConstraint.activate([ collectionView.topAnchor.constraint(equalTo: view.topAnchor), collectionView.bottomAnchor.constraint(equalTo: view.keyboardLayoutGuide.topAnchor), collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), collectionView.trailingAnchor.constraint(equalTo:  view.trailingAnchor) ])
Posted
by