Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwiftUI code is working in iphone but blank screen in ipad?

Though application is universal but ipad screen is blank. I have added checked both iphone and ipad. When running app in iphone works fine, but in ipad is not showing anything.

struct UserListView: View {

    var userName:String
    @State var searchString:String = ""

    var body: some View {

        VStack {
            SearchBar(text: $searchString)
                    .padding()
                    .frame(height:44)
                    .foregroundColor(Color.white)
                    .background(Color.gray)

            List(userList) { user  in
                   NavigationLink(destination:UserDetailView(userObj:user)) {

                    UserListRow(userObj: user)
                       }.navigationBarTitle("User Detail")
                    }
           }
      }
}
like image 923
Rock Avatar asked Sep 12 '19 11:09

Rock


People also ask

Does SwiftUI work on iPad?

Along with the introduction of tables on iPad, SwiftUI now supports sections in tables on iPad and the Mac.

Why does my screen go black when I open an app iPhone?

iPhone screen stuck black with a white Apple logo? If the iPhone screen goes black but shows a white  Apple logo before returning to normal, this indicates the device is rebooting. If that happens out of the blue, it usually suggests the iPhone is crashing or an app is crashing which causes the device reboot.


2 Answers

Add this modifier to the NavigationView it should work:

NavigationView {

}.navigationViewStyle(StackNavigationViewStyle())
like image 153
Ekambaram E Avatar answered Oct 02 '22 01:10

Ekambaram E


The screen is probably blank because nothing has been selected and there is nothing in the details view so you're seeing a blank details view. If you swipe in from the left side of the screen, the hidden master view will slide over and you can select an item to view the details in the main view.

I hope this is a SwiftUI bug (at at least a missing features) because I don't think anyone wants split views to work like this.

like image 22
sirshannon Avatar answered Oct 02 '22 02:10

sirshannon