I have noticed that Xcode fails to compile with
The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions
You can execute the below demo project to recreate the error. Once you uncomment confirmationDialog entries 11+ it fails to compile.
//
// ContentView.swift
// confDialogTest
//
// Created by Max on 13.06.22.
//
import SwiftUI
struct ContentView: View {
@State private var showingConf1 = false
@State private var showingConf2 = false
@State private var showingConf3 = false
@State private var showingConf4 = false
@State private var showingConf5 = false
var body: some View {
Button(role: .destructive) {
self.showingConf1.toggle()
} label: {
Label("Conf 1", systemImage: "trash.fill")
}
.padding()
Button(role: .destructive) {
self.showingConf2.toggle()
} label: {
Label("Conf 2", systemImage: "trash.fill")
}
.padding()
Button(role: .destructive) {
self.showingConf3.toggle()
} label: {
Label("Conf 3", systemImage: "trash.fill")
}
.padding()
Button(role: .destructive) {
self.showingConf4.toggle()
} label: {
Label("Conf 4", systemImage: "trash.fill")
}
.padding()
Button(role: .destructive) {
self.showingConf5.toggle()
} label: {
Label("Conf 5", systemImage: "trash.fill")
}
// .padding()
.confirmationDialog("Select location", isPresented: $showingConf1, titleVisibility: .visible) {
Text("Conf")
}
.confirmationDialog("Select location", isPresented: $showingConf2, titleVisibility: .visible) {
Text("Conf")
}
.confirmationDialog("Select location", isPresented: $showingConf3, titleVisibility: .visible) {
Text("Conf")
}
.confirmationDialog("Select location", isPresented: $showingConf4, titleVisibility: .visible) {
Text("Conf")
}
.confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
Text("Conf")
}
//next group is dialogs 6-10
.confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
Text("Conf")
}
.confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
Text("Conf")
}
.confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
Text("Conf")
}
.confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
Text("Conf")
}
.confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
Text("Conf")
}
//next group is dialogs 11-15
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
//next group is dialogs 16-20
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
// .confirmationDialog("Select location", isPresented: $showingConf5, titleVisibility: .visible) {
// Text("Conf")
// }
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Whiel it is easy to fix here if I just move some confirmationDialogs to another Button view, I have the same problem in another problem where I have to add many modifiers to a NavigationLink in a List View and there I cannot move it around ... :/
Any ideas what to do here?
Max
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
With the below code I get a very weird scrolling behaviour in my TabViews, LoginView is called on app launch:
struct LoginView: View {
@State private var presentContent = false
var body: some View {
return NavigationView {
ZStack{
NavigationLink(
destination: ContentView(),
isActive: $presentContent,
label: {
EmptyView()
})
Button("TEst") {
self.presentContent.toggle()
}
}
}
}
}
struct ContentView: View {
var body: some View {
TabView{
Group{
List{
Text("Item 1")
Text("Item 2")
Text("Item 3")
}
}
.navigationTitle("Transactions")
.tabItem {
Image(systemName: "list.dash")
Text("Transactions")
}
Group{
List{
Text("Item 11")
Text("Item 12")
Text("Item 13")
}
}
.navigationTitle("Summary")
.tabItem {
Image(systemName: "list.dash")
Text("Summary")
}
}
}
}
Example image below:
Any ideas what that might cause?
Hi,
After the update to big sur I have the issue that when I go to the Lock Screen and select a different user to log in, the screen freezes and after a few seconds the computer reboots.
Any ideas how to fix this?
Max
Hi,
I want to open a view after taping on a push notification. The views and notifications are all working fine but my problem is when I try to open the view from the push notification via .sheet(isPresented) it is always presenting the view as modal.
I would like to achieve that the view is actually opened embedded in the NavigationView it would usually be when accessing it manually.
To make it more clear:
import SwiftUI
struct ContentView: View {
		var body: some View {
NavigationView{
VStack{
NavigationLink(destination: ListView()){
Text("Going one level down")
}
}
}
		}
}
struct ContentView_Previews: PreviewProvider {
		static var previews: some View {
				ContentView()
		}
}
struct ListView: View {
var body: some View{
NavigationLink(destination: DetailView()){
Text("Click me")
}
}
}
struct DetailView: View {
var body: some View{
Text("I want to display this view after tapping on a notification.")
}
}
After tapping on the push notification, I want to jump directly to the DetailView() down in the NavigationView tree (similar to what the Apple Calendar app is doing when you tap on the notification).
Any ideas? :)
Max
Hi,I have a view that displays pictures loaded via web service call. The model for the view is@ObservedObject private var pictureController: PictureController = PictureController()The pictures are provided in an array from the controller:@Published var images:[Picture] = []and the View displays the data from the array with a List (my Picture class conforms to the Identifiable protocol)List(pictureController.images){ item in
Text(item.bkey)
}When loading the pictures from the web service, I store them in a buffer array and afterwards copy the array over to the images arrayDispatchQueue.main.async {
self.images = self.imageBuffer
completionHandler(true)
}I call the controller in the View's onAppear()self.pictureController.fetchPicturesByTask(bkey_issue: self.bkey_task, completionHandler: { success in
print(self.pictureController.images.count)
self.pictureController.images.forEach(){picture in
print(picture.id)
print(picture.bkey!)
}
})Here is the thing: self.pictureController.images.count actually return the proper count of items in the array, the prints below show the correct values but for whatever reason, the List in the View does not get updated ...Just for the sake of it I have also added a button to the View that calls a function on the controller to manually add dummy items to the array and that works perfect ...Any ideas what I am missing here?Max
for Hi,I am retrieving data from a web service in an URLSession and store all the entries to an arrayself.warehouseOrders.append(warehouseOrder)The array is used in another view as data source for a List() item but now I get this error message:Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates.My question is: where is SwiftUI expecting me to put the operator receive(on:)) to fix this?I have kinda solved it by changing the code toDispatchQueue.main.async {
self.warehouseOrders.append(warehouseOrder)
}but I am not sure if that is the correct approach here?See https://forums.developer.apple.com/thread/128068for more details on my code - I have actually posted this already there as a reply but for some reason it still gets moderated for almost 24 hours ...Max