Reputation: 1510
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")
}
}
}
}
Upvotes: 22
Views: 3646
Reputation: 19
I've found a simple work around for this!
If you just check the device type and then insert an empty view for the iPad case, the empty view will be inserted into the shelf and your target view will be displayed.
struct NotificationsControlView: View {
var body: some View {
NavigationView{
if UIDevice.current.userInterfaceIdiom == .pad {
EmptyView()
NotificationsView().navigationViewStyle(.stack)
.navigationBarTitleDisplayMode(.inline)
.hiddenNavigationBarStyle()
} else {
NotificationsView()
.navigationViewStyle(.stack)
.navigationBarTitleDisplayMode(.inline)
.hiddenNavigationBarStyle()
}
}.navigationViewStyle(StackNavigationViewStyle())
}
}
Upvotes: 0
Reputation: 1262
Add this modifier to the NavigationView it should work:
NavigationView {
}.navigationViewStyle(StackNavigationViewStyle())
Upvotes: 54
Reputation: 306
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.
Upvotes: 16