What's new in SwiftUI

RSS for tag

Discuss the WWDC22 Session What's new in SwiftUI

Posts under wwdc2022-10052 tag

17 Posts
Sort by:
Post not yet marked as solved
1 Replies
146 Views
Is it possible to use create a "nonmodal sheet" as described in the Human Interface Guidelines and as seen in apps like Maps using SwiftUI's .sheet and the new .presentationDetents modifier in iOS 16. By default, the content behind the sheet is not interactive. Is there a built in modifier or modality style that can be applied to the sheet to allow for interactive content behind the sheet?
Posted Last updated
.
Post marked as solved
4 Replies
67 Views
I have tried to copy the code from a WWDC 2022 presentation. It worked successfully once, and now I am trying to copy a different point of code later in the same presentation. It keeps giving me the code that I have already copied. Any ideas on how to get this to work would be great! Thank you, Bob
Posted
by BLawson.
Last updated
.
Post not yet marked as solved
1 Replies
128 Views
So I have a navigationStack which has a NavigationLink that navigates to the next view. That view then has its own NavigationLink that navigate to a 3rd view. if the user clicks on the back button on the 3rd view (View3) to return to the previous view (View 2), it goes right back to the starting view (View 1). an one else have this issue or know how to fix? ios16b1 example below: View 1: NavigationStack {                 View2()                     .navigationTitle("View 2")             } View 2: List {        VStack (alignment: .leading) {                     NavigationLink("View 3", destination: {                         View3()                     }) } }
Posted
by ngb.
Last updated
.
Post not yet marked as solved
3 Replies
323 Views
I can't seem to find a way to change List's background color. Modifier .background() has no effect on List background color. Putting List in a ZStack & applying .background modifier to it also has no effect I know that starting with iOS 16 List is backed by UICollectionView so old tricks with .appearance() does not work anymore. Using ZStack with .plain list style also has no effect. Intospecting view hierarchy kinda works but List resets its bg color on update List is such a fundamental component and having no ability to change its background color is very limiting
Posted Last updated
.
Post not yet marked as solved
6 Replies
703 Views
In SwiftUI 3 we used the following code snippet to set the background color of a list. struct ContentView: View {     var body: some View {         List {             Text("Hello World!")         }         .onAppear { // Placed here for sample purposes, normally set globally             UITableView.appearance().backgroundColor = .clear         }         .listStyle(.insetGrouped)         .background(Color.red)     } } This is not working anymore in SwiftUI 4 (FB10225556) as the List is not based on UITableView anymore. Any workaround ideas?
Posted
by saibot.
Last updated
.
Post marked as solved
2 Replies
159 Views
Dear All, How do I share a PDFDocument using the new ShareLink of the SwiftUI? The following code does not compute: let pdf = PDFDocument(data: data) ShareLink(items: pdf.dataRepresentation()!) Thanks.
Posted
by tomas.bek.
Last updated
.
Post not yet marked as solved
2 Replies
177 Views
The new NavigationSplitView is very handy. I want to use it for a settings screen, but I need a way to navigate in and out of it. Previously I just navigated in and out of my settings using a NavigationView. But if I change this to a NavigationStack, and then navigate forward into a NavigationSplitView from it, it almost works fine, but some weirdness happens: on iPhone there are two competing back arrows (i.e "<") and on an iPad there is weird spacing at the top of the screen. Should I be able to navigate from a NavigationStack into a NavigationSplit View? If so, are these known issues? If not, is there a recommended UI for navigating in and out of a NavigationSplitView from the rest of my iPhone/iPad app? thanks!
Posted
by breville.
Last updated
.
Post not yet marked as solved
0 Replies
106 Views
There seems to be no way to add dynamically add table columns to SwfitUI table. I have a column of dates that I store in an array like so. let dates = [Date] let values = [Int] I want one able enumerate over the dates to generate columns. However I can't seem to find a way to enumerate over them and generate my columns. My current data set has 250 columns and it will keep growing. I would love to do ForEach(0 ..< dates.length) { index in TableColumn("<some formatted date>") { Text("\(value)") } } But it appears that since TableColumn is not a view ForEach can't be used. Is there a supported way to build columns dynamically? This is a Mac application. Does charts support a for each type symantic too?
Posted Last updated
.
Post not yet marked as solved
1 Replies
106 Views
I was playing around with TableColumn api in MacOS Ventura I have the following data model. actor HousingData: Identifiable {     let id: Int     let rank: Int     let region: String     let regionType: RegionType     let state: String } However when it try to do TableColumn("foo", value: \.rank) I get Key path value type 'Int' cannot be converted to contextual type 'String' if I try TableColumn("Rank", value: \.rank) { rank in Text("\(rank)") } I get Referencing initializer 'init(_:value:content:)' on 'TableColumn' requires the types 'Never' and 'KeyPathComparator<HousingData>' be equivalent If i use a string value all works well.
Posted Last updated
.
Post not yet marked as solved
0 Replies
142 Views
Dear All, Recent updates in SwiftUI allow to add scope bars just beneath the search bar. Those are limited in space, though. How does one implement a scrollable filter as is seen in the Apple’s own Developer app?
Posted
by tomas.bek.
Last updated
.
Post not yet marked as solved
2 Replies
282 Views
My question concerns a macOS SwiftUI app. I would like to have a split view with 2 horizontal panes without sidebar: content on the left and inspector on the right. The inspector should act like the inspector panel on the right side side of the Xcode's window: when the window is resized, the inspector keeps it's current width and the user can resize the inspector using the split divider. Using macOS Monterey SDK, I tried to achieve this with HSplitView but the problem is that the left/right panels are both resized when the window is resized. struct ContentView: View { var body: some View { HSplitView { Rectangle().fill(.red) Rectangle().fill(.yellow) } } } Using Ventura SDK, I just tried the new view NavigationSplitView. I'm using .constant(.doubleColumn) to hide the sidebar but the problem is the same as HSplitView, the left/right panel are both resized when the window is resized. struct ContentView: View { var body: some View { NavigationSplitView(columnVisibility: .constant(.doubleColumn)) { Text("not used") } content: { Rectangle().fill(.red) } detail: { Rectangle().fill(.yellow) } } } When using NSSplitViewController with AppKit, the holdingPriority (https://developer.apple.com/documentation/appkit/nssplitviewitem/1388887-holdingpriority?language=objc) allows to manage this case: The view with the lowest priority is the first to gain additional width if the split view grows or shrinks. Is it possible to achieve this with SwiftUI?
Posted
by benoit.
Last updated
.
Post not yet marked as solved
1 Replies
221 Views
The new ImageRenderer in SwiftUI is really great and should help me to remove some custom code I've had to write in the past. I've noticed that when used to capture a view that contains a map view, the map is replaced with a 'no entry' sign 🚫 Is this intentional? Here's some sample code to replicate the issue: https://gist.github.com/shaundon/282cf7ff276093681a1c246ae318c9d4
Posted
by shaundon.
Last updated
.