Post

Replies

Boosts

Views

Activity

Thread 1: Fatal error: No ObservableObject of type msgDatas found. A View.environmentObject(_:) for msgDatas may be missing as an ancestor of this view.
I have simple app, when I run my project it work, but then throw error after running like "Thread 1: Fatal error: No ObservableObject of type msgDatas found. A View.environmentObject(_:) for msgDatas may be missing as an ancestor of this view." struct Home: View {   @EnvironmentObject var data : msgDatas       var body : some View{           ZStack{               Color("bg").edgesIgnoringSafeArea(.top)               NavigationLink(destination: Message(), isActive: $data.show) {                 Text("")       }       VStack{                   topView()       }     }   } }
2
0
1.7k
Mar ’21
Using slide menu with bottom navigation bar
I have a simple slide menu project in SwiftUI, and I want to add bottom navigation bar in my project, but when I click the slide menu button, I want to draw bottom navigation bar as well like in image. - https://stackoverflow.com/questions/66693507/using-slide-menu-with-bottom-navigation-bar Any idea will be appreciated. Drawer: struct Home: View { // Hiding tab Bar... init() { UITabBar.appearance().isHidden = true } @StateObject var menuData = MenuViewModel() @Namespace var animation var body: some View { HStack(spacing: 0){ // Drawer And Main View... // Drawer... Drawer(animation: animation) // Main View... TabView(selection: $menuData.selectedMenu){ Catalogue() .tag("Catalogue") Orders() .tag("Your Orders") Cart() .tag("Your Cart") Favourites() .tag("Favourites") } .frame(width: UIScreen.main.bounds.width) } // Max Frame... .frame(width: UIScreen.main.bounds.width) // Moving View.... // 250/2 = 125.... .offset(x: menuData.showDrawer ? 125 : -125) .overlay( ZStack{ if !menuData.showDrawer{ DrawerCloseButton(animation: animation) .padding() } }, alignment: .topLeading ) // Setting As Environment Object.... // For Avoiding Re-Declarations... .environmentObject(menuData) } }
0
0
934
Mar ’21
Using sidebar menu with tabbar in SwiftUI
I have sidebar menu, I want to integrate with my app. In app, I have tabbar, sidebar menu not work correctly with tab bar. Any idea will be appreciated? var body: some View { SideMenuView() TabView(selection: $selection){ PeopleView() .tabItem { selection == 0 ? Image("people-selected") : Image("people") } .tag(0) AnimalView() .tabItem { selection == 1 ? Image("animal-selected") : Image("animal") } .tag(1) PlantsView() .tabItem { selection == 2 ? Image("plants-selected") : Image("plants") } .tag(2) }
0
0
789
Mar ’21
Click circle image and navigate new SwiftUI
I have custom search bar and custom circle image in toolbar, when I click the circle image, I want to navigate new SwiftUI. Any idea will be appreciated. ImageView: VStack(alignment: .leading, spacing:0){              HStack(spacing: 0){                 TextField("Search", text: $search)           .padding(.vertical,5)           .padding(.horizontal)           .background(Color.gray.opacity(0.090))           .cornerRadius(30)           .frame(width: 330, height: 32)                  Image("imgage")           .resizable()           .aspectRatio(contentMode: .fill)           .frame(width: 32, height: 32)           .clipShape(Circle())           .overlay(Circle().stroke(Color("fig"), lineWidth: 1))               } } ContentView: var body: some View {    //I have tabview here// }
9
0
2.3k
Mar ’21
How to navigate from side menu in SwiftUI to new SwiftUI.
I have side bar menu in my project, it is work correctly, but I want to use every side bar option menu, when I click any side bar menu, it may router to other Swift UI. How can I create Swift UI for every side option menu? SideMenuViewModel: enum SideMenuViewModel: Int, CaseIterable { case profile case lists case bookmarks case messages var title: String { switch self { case .profile: return "Profile" case .lists: return "lists" case .bookmarks: return "bookmarks" case .messages: return "messages" }} var imageName: String { switch self { case .profile: return "profile" case .lists: return "list.bullet" case .bookmarks: return "bookmark" case .messages: return "message" }}} SideMenuView: struct SideMenuView: View { @Binding var isShowing: Bool var body: some View { ZStack { LinearGradient(gradient: Gradient(colors: [Color("red"), Color("blue")]), startPoint: .top, endPoint: .bottom) .ignoresSafeArea() VStack { SideMenuHeaderView(isShowing: $isShowing) .frame(height: 240) ForEach(SideMenuViewModel.allCases, id:\.self) { option in NavigationLink( destination: Text(option.title), label: { SideMenuOptionView(viewModel: option) })} Spacer() }}.navigationBarHidden(true) }}
0
0
738
Mar ’21