Post

Replies

Boosts

Views

Activity

Cannot update view
The variable from SignInController changes, the view does not. import SwiftUI import Foundation class SignInController: ObservableObject { var signedIn: Bool = false } struct MainView: View { @StateObject var signCon = SignInController() var body: some View { return Group { if signCon.signedIn == false { ZStack { SignView() Button { signCon.signedIn.toggle() print(signCon.signedIn) } label: { Text("Make True") } } } else if signCon.signedIn == true { HomeView() } } } } struct MainView_Previews: PreviewProvider { static var previews: some View { MainView() } } extension UserDefaults { func valueExists(forKey key: String) -> Bool { return object(forKey: key) != nil } }
1
0
364
Dec ’21
.navigationViewStyle(.columns) doesn't work
Hi, I'm trying to do basic app with fixed Navigation View on iPad. Doesn't work. What am I doing wrong? import SwiftUI struct CollectionView: View {     var body: some View {         if #available(iOS 15.0, *) {             NavigationView {                                  Text("Hello")                                      .navigationTitle("Hello")             }             .navigationViewStyle(.columns)             .padding()         } else {             // Fallback on earlier versions         }     } } struct CollectionView_Previews: PreviewProvider {     static var previews: some View {         CollectionView()     } }
1
0
450
Oct ’21
'ColumnNavigationViewStyle' initializer is inaccessible due to 'internal' protection level
Hi, trying simply using new ColumnNavigationViewStyle and getting error in title on using it. struct CollectionView: View {     var body: some View {         NavigationView {                      Text("Hello")                          .navigationTitle("Hello")         }         .navigationViewStyle(ColumnNavigationViewStyle())     } } struct CollectionView_Previews: PreviewProvider {     static var previews: some View {         CollectionView()     } }
1
0
903
Oct ’21