Was going through my app to clean up the UI for Ipad's and receiving a weird issue. When I go to navigate to one of my views, the view automatically closes once opening and I receive the following error:
Failed to create 0x88 image slot (alpha=1 wide=0) (client=0xxxxxx) [0x5 (os/kern) failure]
It started occurring when I incorporated .navigationViewStyle(StackNavigationViewStyle())
on my view to discard splitview from showing up on Ipads. When I remove it works fine, but splitview would then be shown.
NavigationView{
//DISPLAY USERS
ScrollView{
ForEach ((vm.allUsers), id:\.id ) { user in
// localizedCaseInsensitiveContains(searchText)
if user.name.localizedCaseInsensitiveContains(userSearch) || user.gender.contains(userSearch) || user.weight.contains(userSearch) || user.height.contains(userSearch) {
FollowingListRow(userUID: user.uid ,userName: user.name,userBio: user.userBio ,userProfileImage: user.profilePictureURL, userExercisePreferences: user.exercisePreferences, userSocialLink: user.userSocialLink)
}
}
}
.padding(.top, 15) // << add separation from list and search bar
.navigationBarTitle("Search")
//SEARCH
.searchable(text: $userSearch ,placement: .navigationBarDrawer(displayMode: .always), prompt: "Search by gender, height or weight") // << always display search bar
.disableAutocorrection(true) // << disable autocorrect
}
.navigationViewStyle(StackNavigationViewStyle()) // << for ipad styling
}
}
View B
NavigationLink(destination: UserProfileView(userUID: userUID, name: userName, userBio: userBio, userProfilePicture: userProfileImage, journalCount: jm.userJournalCountNonUser, rm: rm, jm: jm, userSocialLink: userSocialLink, exercisePreferences: userExercisePreferences).padding(.top, -65) ){
VStack{
VStack{
HStack{
WebImage(url: URL(string: userProfileImage))
.placeholder(Image("profileDefaultPicture"))
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width:60, height: 60)
.clipShape(Circle())
.padding(.leading, 20)
.padding(.trailing, 25)
VStack{
HStack{
Text("TestName)
.font(.title)
Spacer()
}
}
User Profile (View C)
var body: some View {
GeometryReader { Geo in
VStack{
WebImage(url: URL(string: userProfilePicture))
.placeholder(Image("profileDefaultPicture").resizable())
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width:150, height: 150)
.clipShape(Circle())
HStack{
Text(name ?? "" ).bold()
.font(.title2)
.padding(.bottom, 2)
}
}
Try to remove the .navigationBarTitle("Search") sometimes when you add a title to the main view (the view that has the NavigationView) while you using the StackNavigationViewStyle with iPad this error appears. I don't know how to fix this (maybe it is a bug) but as a workaround, you can try to remove navigationBarTitle and add the title to the main view like this:
NavigationView {
VStack {
HStack {
// this is your navigation bar
Text("Your Title")
.padding()
}
VStack {
// all your contents here...
}
.frame(maxWidth: .infinity,maxHeight: .infinity) // <- add this
}
}
.navigationViewStyle(StackNavigationViewStyle())
So in your case maybe your code will be something like this:
NavigationView {
VStack {
// this is your navigation bar
HStack {
Text("Search") // <- Your title is here
.padding()
}
// put all your view contents here - below
//DISPLAY USERS
ScrollView {
ForEach ((vm.allUsers), id:\.id ) { user in
// localizedCaseInsensitiveContains(searchText)
if user.name.localizedCaseInsensitiveContains(userSearch) || user.gender.contains(userSearch) || user.weight.contains(userSearch) || user.height.contains(userSearch) {
FollowingListRow(userUID: user.uid ,userName: user.name,userBio: user.userBio ,userProfileImage: user.profilePictureURL, userExercisePreferences: user.exercisePreferences, userSocialLink: user.userSocialLink)
}
}
}
.padding(.top, 15) // << add separation from list and search bar
// .navigationBarTitle("Search") // <- remove this
//SEARCH
.searchable(text: $userSearch ,placement: .navigationBarDrawer(displayMode: .always), prompt: "Search by gender, height or weight") // << always display search bar
.disableAutocorrection(true) // << disable autocorrect
.frame(maxWidth: .infinite, maxHeight: .infinite) // <- this is important to add at the top container View of your content
}
}
.navigationViewStyle(StackNavigationViewStyle()) // << for ipad styling
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With