Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.

All subtopics

Post

Replies

Boosts

Views

Activity

TextKit2 to PDF WITHOUT Font embedding
I can render text from TextKit2 into a PDF everything is fine. But in this case the font is embedded into the PDF. I need the Pdf to contains only the paths / glyphs and not font. I can't find a solution yet. I don't want to create an image or using UIViews etc. It would be nice to get the bezier path of the text I have done this with TextKit1 but the glyphs are gone with TextKit2 Can anyone help me ? Thanks :)
0
0
4
32m
SwiftUI "scaleEffect(..)" commentary
I've a SwiftUI-based app that draws into a Canvas for a complicated, dynamic rendering. Since that rendering is based on a map of the world, I transform the provided context to (±180°×±90°) longitude / latitude coordinates before stroking paths etc. Note that the necessary scaling flips the Y-axis because latitude increases up the screen. All is well until I add words to the picture. Because of the inversion of the Y-axis, the text is rendered inverted. mercatorContext.draw(Text(satellite.commonName) .font(Font(.init(.userFixedPitch, size: 4.0))) .foregroundColor(.white), at: satPoint) My solution was to draw the text via a another (un-inverted) context which corrects the words, but requires the satPoint to be flipped to place the words at the right place on the (inverted) map .. With that preamble, someone suggested I apply scaleEffect(y: -1) to the Text and avoid messing with more than one GraphicsContext. This seemed an excellent solution but it doesn't work .. context.draw(Text(.. draws a Text view but applying scaleEffect turns it into a View which context.draw can't accept. Once it's a View, I suppose I could convert it to an Image and context.draw(Image(.. instead which seems messy. I wondered about the scaleEffect function .. is it the case that it would ever actually return a view type that was different from the type it was given? Leaving my curiosity aside, what would a better way than using a second context to keep my text upright?
0
0
37
7h
Trouble navigation from detail view to grid view (root view) in app using SwiftData
I am writing an Library app that shows a grid. Each grid location shows the book cover and some info about the book. If the user clicks on a cover, the detail view opens. One option that the user has is a delete the book button. This button deletes the book from SwiftData, but the detail page remains populated. The simple way I want to handle this is to have the delete button also return to the grid view (eg root). Here is the relative code from the CurrentView @State private var path = [Book]() var body: some View { NavigationStack(path: $path) { BookListView(sort: sortOrder, searchString: searchText) .navigationTitle("Library") .navigationDestination(for: Book.self, destination: EditBookView.init) .searchable(text: $searchText) Here is the code from the Grid View var body: some View { LazyVGrid (columns: gridLayout) { ForEach(books) { book in NavigationLink(value: book) { GridRow { VStack { Here is the code from the Detail View var body: some View { Form { VStack (spacing: 0){ BookImageView(book: book) } TextField("Title", text: $book.title) Button("Go Back to ListView", action: { // Action to perform }) } .navigationTitle("Edit Book") .navigationBarTitleDisplayMode(.inline) } // Form } // some View Can you provide the code for the button "Go Back to Last View"
0
0
39
12h
About NavigationLink Inside NavigationSplitView's Sidebar
Hello, In the code below, I want to navigate back to the SecondView when pressing the back button in the ThirdView. However, it navigates to the FirstView instead. How can I make it navigate back to the SecondView without going to the FirstView? struct FirstView: View { var body: some View { NavigationSplitView { Text("Here is the FirstView") NavigationLink("Go to SecondView") { SecondView() } } detail: { EmptyView() } } } struct SecondView: View { var body: some View { Text("Here is the SecondView") NavigationLink("Go to ThirdView") { Text("Here is the ThirdView") } } }
0
0
45
23h
How to customise text field? tvOS
I'd like to customise text fields in my application, but I don't see any options for it. When I click text field, new window opens. And there is no title or description. But there must be something that allows me to customize it, right? Apple applications contain customised text fields. This is apple's text field (after clicking on it) This is my text field (after clicking on it) Here is my code: Form { //... TextField("", text: $address) //... } And there is one more problem. After filling this TextField I click enter and it immediately opens the next TextField. I don't want this behaviour.
0
1
44
1d
Diffable datasource and how to add new items / use snapshots properly
First question: I'd like to get clarification on what code I have to write to add a new item to a UICollectionView. So far, I have managed to seed my datasource with some sample data, which correctly appears in the collectionView. snapshot.appendSections(sections) // assume there is only 1 section. snapshot.appendItems(["addBoat"], toSection: .Boat)// placeholder for an add button snapshot.appendItems(backingStore.BoatIdentifiers(), toSection: .Boats)// add the boats in the backing store. dataSource.apply(snapshot, animatingDifferences: false) After the user enters the necessary data for a new boat, my code creates a new item instance (a struct). The sample project DiffableDataSourceSample README states: While a diffable data source can determine the changes between its current snapshot and a new one, it doesn't monitor the data collection for changes. Instead, it's the responsibility of the app to detect data changes and tell the diffable data source about those changes, by applying a new snapshot. So does that really mean that when I add one new item, I have to 1) add it to my backing store, and then 2) create a new snapshot with all the data in my backing store so that I can 3) apply that to the dataSource? Intuitively, if my backing store has a couple thousand items, step 2 feels it could be very costly. I was expecting that I could just append the new item to the existing snapshot (the one I created when seeding the data). But that means I have to keep the snapshot alive (and pass it around viewControllers). Something like this: snapshot.appendItems(newBoat.id, toSection: .Boats) Second, related question: I need to check that a new item doesn't already exist. Do I need to check in the existing snapshot? Like this: if let index = snapshot.indexOfItem(newBoat.id) { ... // boat is duplicate, don't allow adding it. } Or do I check only in my backing store, and then do steps 1 2 and 3 above? Thanks for any help.
0
0
19
1d
NSTableView cells disappear on macOS Sonoma
Hi, i have an old popover status bar mac app that i didn't check in the past few macOS releases, so don't know when the problem appeared. On Sonoma i have the following problem: All NSTableViews cells when they are reused the second time, they are blank. The cells are of type view and only one column. If i investigate in the Xcode's view hierarchy I indeed see no subviews in the cell, but if i print the subviews and their frames and their visibility, they are there alright, they exist. All the cells are instantiated from nib and I tried few strategies to use them: register the cell in the tableview and load it with tableView.makeView(withIdentifier: ) no registration, just load them from xib and keep a reference to their instance and feed that to the table when asked no registration, load them from xib when the table asks. This solution actually works but i really need a reference to them that doesn't change, it's a settings screen and someone else is feeding some info to this cells. I'm stuck, I have no idea what is happening, can you think of something? Thanks!
0
0
40
1d
iOS18 WebView Crash
There is a 'WebCore::CachedResource::removeClient(WebCore::CachedResourceClient&)' crash in iOS 18 version. Could you please tell me if there are any changes to the WebView regarding this crash and how to debug it?
0
0
46
1d
UISplitViewController column-style, bug in setViewController?
&TLDR; I see no documentation stating that during the life of UISplitViewController, that I cannot call setViewController(xxxxx, column) more than once on the same column. Yet in my experience calling it a second time does not work, unless I set the value to nil before calling it again to set it to the new value... I'm using a UISplitViewController in newer column-style layout and when bootstrapping the app, I create the UISplitViewController and use setViewController(primaryViewController, .primary) and setViewController(detailViewController, .secondary). In order to use the primaryViewController for the compact scenario, I return the .primary column in the UISplitViewControllerDelegate method: splitViewController(_ svc: UISplitViewController, topColumnForCollapsingToProposedTopColumn proposedTopColumn: UISplitViewController.Column) -> UISplitViewController.Column Tapping a cell in the primaryViewController, results in a call to splitViewController.show(.secondary) This works for both split view (primary + secondary) as well as in compact mode. Tapping a cell in the secondary viewController results in pushing a new sub-detail onto the navigation sack. Again so far so good. If I switch back to split mode (primary+secondary) it still looks good with secondary showing the sub-detail. If I then collapse into compact view, the primary is once again shown. If I tap a different cell in the primary, the same call to: splitViewController.show(.secondary) results in the sub-detail viewController being shown. Instead, I want the secondary to show the detail for the new selected cell...not the sub-detail of the prior cell. To fix this, I popped the navigation stack for the secondary to rootViewController if secondaryNavigationController.topViewController as? DetailViewController == nil { secondaryNavigationController.popToRootViewController(animated: false) next, I attempted to replace splitViewController's secondary viewController by assigning the secondaryNavigationController which now has the DetailViewController as the top (and only) viewController. splitViewController.setViewController(secondaryNavigationController, for: .secondary) after this assignment, calling splitViewController.viewController(for: .secondary) returns the old sub-detail viewController, not the expected DetailViewController! IMO this is a bug. I found the following solution. First set it to nil, then set it to the desired value. splitViewController.setViewController(nil, for: .secondary) splitViewController.setViewController(secondaryNavigationController, for: .secondary)
0
0
33
1d
Textfield binded string var not clearing when autocorrected
I have a simple text field and a button the textfield text var is binded to my @state string var $strText. the button has an action that sets strText = "" when trying to input "nintendo switch" without a capital N, the textField will auto correct to "Nintendo switch". When pressing the button, the textfield will not clear. I have tried wrapping the button action in a DispatchQueue.main.async but there is no change in behavior. However, adding an .onSubmit{ } view modifier to the text field and calling strText = "" in the onSubmit closure will clear the textField. Is there anyway to have the button action call the textfield's submit trigger? import SwiftUI struct ContentView: View { @State var text: String = "" private func clearText() { print("YAHOOOO 2clear \(self.text)") self.text = "" print("YAHOOOO 2\(self.text)") } var body: some View { VStack { TextField("Message", text: $text, axis: .vertical) .autocorrectionDisabled(false) .onSubmit { clearText() } Button(action: { DispatchQueue.main.async { clearText() } }, label: { Text("Send") }) } .padding() } }
0
0
56
1d
Ultra Action Button showing on screen
When I initiate WKExtendedRuntimeSession with a background mode of "Underwater Depth" I get an orange indicator showing the Action button on the screen that stays showing all the time and then animates when you press the action button. I believe this started with a recent WatchOS update, because it never happened before. Does anyone know how to hide it? Or keep it and be able to detect the Action button presses within my app (if possible)?
1
0
61
1d
Impossible to enter Chinese characters in searchable() field after token insertion
It is impossible to enter Chinese characters after tokens are inserted into .searchable text field. Input is directly converted into Pinyin alphabets without giving the user a chance to choose its corresponding Chinese character. If no view is provided in the "token" view builder of the searchable initializer, then this issue does not happen. I have filed feedback FB13957127. In the meantime, I was wondering if there are any possible workarounds? This bug essentially prevents Chinese users from using the search feature of my app. Thanks!
1
0
55
1d
Why is KeyboardLayoutGuide not applied in viewIsAppearing() in iOS 15.0?
viewIsAppearing is available in iOS 13 and above, and I understand that setting the layout in this lifecycle is a good way to do it. But when I use it, confirmed that UIKeyboardLayout does not work properly in viewIsAppearing in iOS versions lower than 16.0. There is a small problem not only with viewIsAppearing, but also with viewDidLoad(). In viewDidLoad(), the component to which UIKeyboardLayoutGuide is applied is visible when the screen first appears. However, there is a problem where the layout with UIKeyboardLayoutGuide applied is not visible when returning after changing the navigation screen (Push & Pop). I confirmed that UIKeyboardLayoutGuide is applied properly in viewIsAppearing and viewDidLoad in iOS 16.0 and higher versions. Below is the code and environment for reproducing the problem situation. ==================================================== Envirionment: M1 Pro(Sonoma v14.5), Xcode(v15.4), iPhone Simulator (iOS v15.0, v15.2) import UIKit import SnapKit final class ViewController: UIViewController { private let uiTextField: UITextField = { $0.placeholder = "search" $0.backgroundColor = .red return $0 }(UITextField()) override func viewIsAppearing(_ animated: Bool) { super.viewIsAppearing(animated) view.backgroundColor = .white layout() } private func layout() { view.addSubview(uiTextField) uiTextField.snp.makeConstraints { $0.height.equalTo(50) $0.horizontalEdges.equalToSuperview() $0.bottom.equalTo(view.keyboardLayoutGuide.snp.top) } } override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { view.endEditing(true) } } I wonder if I haven't checked what I need to check yet, or if there are other problems.
0
0
54
1d
Opt out of window tiling (macOS 15)
Is there a way to opt certain windows out of tiling in macOS 15? I'm supporting a beloved feature called App Veil[1], which places windows below others that are not owned by the host application. These windows are passive: they don't allow mouse events and cannot be resized or moved. With the new tiling feature on macOS 15, the window manager will rearrange these windows if you choose an arrangement option (such as Arrange Left & Right). Ideally, I'd like to opt out of this behavior altogether for these windows, but I couldn't find a way to do that. The only thing I've found was that I could set a high window level, but that's not really an option as it's important to preserve the ordering so that the windows are directly below the out-of-process windows. 1: https://tuple.app/app-veil
0
0
53
2d
Integrate with the system provided Workout Live Activity in the Apple Watch Smart Stack
When I start a workout in my app, the system shows a Live Activity in the Smart Stack like in the picture. My app opens if I tap on it, but the pause and resume buttons doesn't do anything. I have implemented the PauseWorkoutIntent and ResumeWorkoutIntent which works with the Action Button. I guessed that these would be used from this Live Activity as well, but it seems like not. Has anyone successfully integrated with this? I haven't seen it documented anywhere, although I think it was already included in watchOS 10. This is also shown when using the built in workout app and for that the buttons work as expected.
0
0
36
2d