What's new in SwiftUI

RSS for tag

Discuss the WWDC22 Session What's new in SwiftUI

Posts under wwdc2022-10052 tag

27 Posts

Post

Replies

Boosts

Views

Activity

SwiftUI: Bottom sheet from the iPhone "find my" and "maps" app
I would like to include the bottom sheet from the iPhone "find my" and "maps" app in my app. During my research I came across the new modifier .presentationDetents for sheets. The only problem here is that you can no longer interact with the main screen when the sheet is active. In my app, however, I would like the sheet to be active all the time like in the iPhone apps mentioned and that you can still interact with the main screen like in the iPhone apps with the map. I would be very happy about help. Greetings
10
4
5.7k
Oct ’24
SwiftUI Mixed-state toggles & pickers - WWDC2022 session 10052
I am trying to get mixed-state toggles and pickers to work. I have watched the session (the discussion starts around 17:55). I have copied the example code from the session and I get the same compile error I get with my own code: Cannot convert value of type '[Binding]' to expected argument type 'Binding' I also can not find a Toggle init that is specialized for a Sequence or Array of bindings to values. Did this SwiftUI feature get cut? Has anyone got this working? Any help is greatly appreciated.
1
0
1.3k
May ’23
Change Modality of Sheets in SwiftUI
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?
3
6
4k
Apr ’23
Swift UI TableColumn with Int data
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.
4
0
3.2k
Mar ’23
.searchScopes modifier not adding scope bar to search
I’m unable to use the .searchScopes modifier to add a segmented Picker to my search bar as of developer beta 6. It will not display whether I’m using a NavigationStack, NavigationSplitView, or NavigationView. Has anyone had any luck using this modifier? This simple code will demonstrate the problem. struct ContentView: View {     @State var searchText: String = ""     @State var searchScope: String = "Scope 1"         let data = Array(0..<20)     var body: some View {         NavigationStack {             List {                 ForEach(data, id:\.self) { item in                    Text("\(item)")                 }             }             .searchable(text: $searchText)             .searchScopes($searchScope, scopes: {                     Text("Scope 1")                     Text("Scope 2")             })         }     } } I've submitted this as FB11298015
3
1
1.7k
Nov ’22
ShareLink from Menu cannot popup
Menu {      ShareLink(...) ShareLink(...)      ShareLink(...) } label: {   Label("Share", systemImage: "square.and.arrow.up") } Here, I have different share options to choose from, and if I tap one of these share link to share sheet doesn't pop up. Is there any workaround to this issue?
3
2
1.8k
Oct ’22
SwiftUI 4: Set list background color
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?
8
1
11k
Sep ’22
Navigating in and out of a NavigationSplitView
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!
3
1
1.7k
Sep ’22
App Terminates when using Window and MenuBarExtra in SwiftUI
If you configure a Window and a MenuBarExtra in your app, try this: Open your app and press Command+H to hide it. Place an iPad or another Mac and connect two devices via Universal Control, and click on the other device to make your mac's menu bar inactive. Move your cursor back to your Mac(first device), and click on the whitespace of the Menu Bar. Your App is terminated unexpectedly. This behavior will only appear on those apps using Window, so to solve this issue, we may need to switch Window to WindowGroup which is not what we want. I reappear this issue on Apple's ScreenCaptureKit Sample Code. This is a SwiftUI Scene BUG, please fix this. @main struct CaptureSampleApp: App { var body: some Scene { Window("ID", id: "ID") { ContentView() .frame(minWidth: 960, minHeight: 724) .background(.black) } MenuBarExtra( "App Menu Bar Extra", systemImage: "star" ) { Text("Hello") } } } Filed a feedback: FB11447959.
0
0
1.4k
Sep ’22
SwiftUI 4 ShareLink SharePreview unexpected behavior
When integrating the new ShareLink into my project, I noticed two unexpected things. First, when I pass a SharePreview to my sharelink with just a title and no image as a pararameter, my AppIcon suddenly loads in the preview. Is that normal? Just with that code: ShareLink(item: appStoreUrl, message: Text(["", ""].randomElement()!), preview: SharePreview("ProTimer")) { Label { Text("ProTimer weiterempfehlen") .tint(.primary) } icon: { Image(systemName: "square.and.arrow.up") } } My second question is, why can't I pass a subtitle in the SharePreview, only the title in bold?
0
1
1.2k
Aug ’22
NavigationStack with NavigationLink - back button only works correctly one deep
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()                     }) } }
3
2
1.5k
Jul ’22
Copying the Code from the Developer App
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
4
0
1k
Jul ’22
Can't change List background color in iOS 16
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
4
5
4.5k
Jul ’22
Dynamic TableColumns with ForEach
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?
0
0
1.3k
Jun ’22
SwiftUI Search Bar and Scope Filters
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?
Replies
1
Boosts
2
Views
1.5k
Activity
Jul ’25
SwiftUI: Bottom sheet from the iPhone "find my" and "maps" app
I would like to include the bottom sheet from the iPhone "find my" and "maps" app in my app. During my research I came across the new modifier .presentationDetents for sheets. The only problem here is that you can no longer interact with the main screen when the sheet is active. In my app, however, I would like the sheet to be active all the time like in the iPhone apps mentioned and that you can still interact with the main screen like in the iPhone apps with the map. I would be very happy about help. Greetings
Replies
10
Boosts
4
Views
5.7k
Activity
Oct ’24
SwiftUI Mixed-state toggles & pickers - WWDC2022 session 10052
I am trying to get mixed-state toggles and pickers to work. I have watched the session (the discussion starts around 17:55). I have copied the example code from the session and I get the same compile error I get with my own code: Cannot convert value of type '[Binding]' to expected argument type 'Binding' I also can not find a Toggle init that is specialized for a Sequence or Array of bindings to values. Did this SwiftUI feature get cut? Has anyone got this working? Any help is greatly appreciated.
Replies
1
Boosts
0
Views
1.3k
Activity
May ’23
Change Modality of Sheets in SwiftUI
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?
Replies
3
Boosts
6
Views
4k
Activity
Apr ’23
Swift UI TableColumn with Int data
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.
Replies
4
Boosts
0
Views
3.2k
Activity
Mar ’23
Xcode my First Personal project
I use other people's resources to build projects for others. But I am looking to create the resources to develop my Xcode projects.
Replies
1
Boosts
0
Views
667
Activity
Mar ’23
Where can I download the code of the PartyTask app WWDC2022-10052
Where can I download the code of the PartyTask app and test in xcode? Thx Christian f
Replies
0
Boosts
0
Views
587
Activity
Mar ’23
searchable tokens view
now matter what view i create tor token it takes only first Text/Label element for display. Is it possible to customize it so it would look something like in Mail app ?
Replies
1
Boosts
1
Views
909
Activity
Jan ’23
.searchScopes modifier not adding scope bar to search
I’m unable to use the .searchScopes modifier to add a segmented Picker to my search bar as of developer beta 6. It will not display whether I’m using a NavigationStack, NavigationSplitView, or NavigationView. Has anyone had any luck using this modifier? This simple code will demonstrate the problem. struct ContentView: View {     @State var searchText: String = ""     @State var searchScope: String = "Scope 1"         let data = Array(0..<20)     var body: some View {         NavigationStack {             List {                 ForEach(data, id:\.self) { item in                    Text("\(item)")                 }             }             .searchable(text: $searchText)             .searchScopes($searchScope, scopes: {                     Text("Scope 1")                     Text("Scope 2")             })         }     } } I've submitted this as FB11298015
Replies
3
Boosts
1
Views
1.7k
Activity
Nov ’22
ShareLink from Menu cannot popup
Menu {      ShareLink(...) ShareLink(...)      ShareLink(...) } label: {   Label("Share", systemImage: "square.and.arrow.up") } Here, I have different share options to choose from, and if I tap one of these share link to share sheet doesn't pop up. Is there any workaround to this issue?
Replies
3
Boosts
2
Views
1.8k
Activity
Oct ’22
SwiftUI 4: Set list background color
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?
Replies
8
Boosts
1
Views
11k
Activity
Sep ’22
Navigating in and out of a NavigationSplitView
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!
Replies
3
Boosts
1
Views
1.7k
Activity
Sep ’22
App Terminates when using Window and MenuBarExtra in SwiftUI
If you configure a Window and a MenuBarExtra in your app, try this: Open your app and press Command+H to hide it. Place an iPad or another Mac and connect two devices via Universal Control, and click on the other device to make your mac's menu bar inactive. Move your cursor back to your Mac(first device), and click on the whitespace of the Menu Bar. Your App is terminated unexpectedly. This behavior will only appear on those apps using Window, so to solve this issue, we may need to switch Window to WindowGroup which is not what we want. I reappear this issue on Apple's ScreenCaptureKit Sample Code. This is a SwiftUI Scene BUG, please fix this. @main struct CaptureSampleApp: App { var body: some Scene { Window("ID", id: "ID") { ContentView() .frame(minWidth: 960, minHeight: 724) .background(.black) } MenuBarExtra( "App Menu Bar Extra", systemImage: "star" ) { Text("Hello") } } } Filed a feedback: FB11447959.
Replies
0
Boosts
0
Views
1.4k
Activity
Sep ’22
How to build horizontal scrolling grid like iOS 16 Fitness app's interval modal
The iOS 16 Fitness app has a nice horizontal scrolling view with a pinned first column. Is it possible to build that using SwiftUI's new Grid?
Replies
0
Boosts
0
Views
1.1k
Activity
Sep ’22
SwiftUI 4 ShareLink SharePreview unexpected behavior
When integrating the new ShareLink into my project, I noticed two unexpected things. First, when I pass a SharePreview to my sharelink with just a title and no image as a pararameter, my AppIcon suddenly loads in the preview. Is that normal? Just with that code: ShareLink(item: appStoreUrl, message: Text(["", ""].randomElement()!), preview: SharePreview("ProTimer")) { Label { Text("ProTimer weiterempfehlen") .tint(.primary) } icon: { Image(systemName: "square.and.arrow.up") } } My second question is, why can't I pass a subtitle in the SharePreview, only the title in bold?
Replies
0
Boosts
1
Views
1.2k
Activity
Aug ’22
NavigationStack with NavigationLink - back button only works correctly one deep
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()                     }) } }
Replies
3
Boosts
2
Views
1.5k
Activity
Jul ’22
Copying the Code from the Developer App
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
Replies
4
Boosts
0
Views
1k
Activity
Jul ’22
Can't change List background color in iOS 16
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
Replies
4
Boosts
5
Views
4.5k
Activity
Jul ’22
ShareLink and PDFDocument
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.
Replies
2
Boosts
2
Views
4.5k
Activity
Jul ’22
Dynamic TableColumns with ForEach
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?
Replies
0
Boosts
0
Views
1.3k
Activity
Jun ’22