Runtime error: Failed to create 0x88 image slot (alpha=1 wide=0) [0x5 (os/kern) failure]

huangapple go评论143阅读模式
英文:

Runtime error: Failed to create 0x88 image slot (alpha=1 wide=0) [0x5 (os/kern) failure]

问题

以下是翻译好的部分:

"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
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)
.navigationBarTitle("Search")
//SEARCH
.searchable(text: $userSearch ,placement: .navigationBarDrawer(displayMode: .always), prompt: "Search by gender, height or weight")
.disableAutocorrection(true)
}
.navigationViewStyle(StackNavigationViewStyle())
}"

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()
}
}
}
}
}
}"

用户个人资料(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)
}
}
}
}"

英文:

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.

  1. NavigationView{
  2. //DISPLAY USERS
  3. ScrollView{
  4. ForEach ((vm.allUsers), id:\.id ) { user in
  5. // localizedCaseInsensitiveContains(searchText)
  6. if user.name.localizedCaseInsensitiveContains(userSearch) || user.gender.contains(userSearch) || user.weight.contains(userSearch) || user.height.contains(userSearch) {
  7. FollowingListRow(userUID: user.uid ,userName: user.name,userBio: user.userBio ,userProfileImage: user.profilePictureURL, userExercisePreferences: user.exercisePreferences, userSocialLink: user.userSocialLink)
  8. }
  9. }
  10. }
  11. .padding(.top, 15) // << add separation from list and search bar
  12. .navigationBarTitle("Search")
  13. //SEARCH
  14. .searchable(text: $userSearch ,placement: .navigationBarDrawer(displayMode: .always), prompt: "Search by gender, height or weight") // << always display search bar
  15. .disableAutocorrection(true) // << disable autocorrect
  16. }
  17. .navigationViewStyle(StackNavigationViewStyle()) // << for ipad styling
  18. }
  19. }

View B

  1. 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) ){
  2. VStack{
  3. VStack{
  4. HStack{
  5. WebImage(url: URL(string: userProfileImage))
  6. .placeholder(Image("profileDefaultPicture"))
  7. .resizable()
  8. .aspectRatio(contentMode: .fill)
  9. .frame(width:60, height: 60)
  10. .clipShape(Circle())
  11. .padding(.leading, 20)
  12. .padding(.trailing, 25)
  13. VStack{
  14. HStack{
  15. Text("TestName)
  16. .font(.title)
  17. Spacer()
  18. }
  19. }

User Profile (View C)

  1. var body: some View {
  2. GeometryReader { Geo in
  3. VStack{
  4. WebImage(url: URL(string: userProfilePicture))
  5. .placeholder(Image("profileDefaultPicture").resizable())
  6. .resizable()
  7. .aspectRatio(contentMode: .fill)
  8. .frame(width:150, height: 150)
  9. .clipShape(Circle())
  10. HStack{
  11. Text(name ?? "" ).bold()
  12. .font(.title2)
  13. .padding(.bottom, 2)
  14. }
  15. }

答案1

得分: 1

尝试在向主视图(具有NavigationView的视图)添加标题时,有时候需要删除**.navigationBarTitle("Search"),当您在iPad上使用StackNavigationViewStyle时,可能会出现此错误。我不知道如何修复这个问题(也许这是一个错误),但作为一种解决方法,您可以尝试删除navigationBarTitle**并像这样将标题添加到主视图:

  1. NavigationView {
  2. VStack {
  3. HStack {
  4. // 这是您的导航栏
  5. Text("Your Title")
  6. .padding()
  7. }
  8. VStack {
  9. // 这里放置所有您的内容...
  10. }
  11. .frame(maxWidth: .infinity, maxHeight: .infinity) // <- 添加这一行
  12. }
  13. }
  14. .navigationViewStyle(StackNavigationViewStyle())

所以在您的情况下,您的代码可能类似于这样:

  1. NavigationView {
  2. VStack {
  3. // 这是您的导航栏
  4. HStack {
  5. Text("Search") // <- 您的标题在此
  6. .padding()
  7. }
  8. // 将所有视图内容放在这里 - 下面
  9. // 显示用户
  10. ScrollView {
  11. ForEach((vm.allUsers), id: \.id) { user in
  12. if user.name.localizedCaseInsensitiveContains(userSearch) || user.gender.contains(userSearch) || user.weight.contains(userSearch) || user.height.contains(userSearch) {
  13. FollowingListRow(userUID: user.uid, userName: user.name, userBio: user.userBio, userProfileImage: user.profilePictureURL, userExercisePreferences: user.exercisePreferences, userSocialLink: user.userSocialLink)
  14. }
  15. }
  16. }
  17. .padding(.top, 15) // 添加与列表和搜索栏之间的间距
  18. // 不要显示标题,移除下面这行
  19. // .navigationBarTitle("Search")
  20. // 搜索
  21. .searchable(text: $userSearch, placement: .navigationBarDrawer(displayMode: .always), prompt: "Search by gender, height or weight")
  22. .disableAutocorrection(true)
  23. .frame(maxWidth: .infinite, maxHeight: .infinite)
  24. }
  25. }
  26. .navigationViewStyle(StackNavigationViewStyle()) // iPad 样式
英文:

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:

  1. NavigationView {
  2. VStack {
  3. HStack {
  4. // this is your navigation bar
  5. Text(&quot;Your Title&quot;)
  6. .padding()
  7. }
  8. VStack {
  9. // all your contents here...
  10. }
  11. .frame(maxWidth: .infinity,maxHeight: .infinity) // &lt;- add this
  12. }
  13. }
  14. .navigationViewStyle(StackNavigationViewStyle())

So in your case maybe your code will be something like this:

  1. NavigationView {
  2. VStack {
  3. // this is your navigation bar
  4. HStack {
  5. Text(&quot;Search&quot;) // &lt;- Your title is here
  6. .padding()
  7. }
  8. // put all your view contents here - below
  9. //DISPLAY USERS
  10. ScrollView {
  11. ForEach ((vm.allUsers), id:\.id ) { user in
  12. // localizedCaseInsensitiveContains(searchText)
  13. if user.name.localizedCaseInsensitiveContains(userSearch) || user.gender.contains(userSearch) || user.weight.contains(userSearch) || user.height.contains(userSearch) {
  14. FollowingListRow(userUID: user.uid ,userName: user.name,userBio: user.userBio ,userProfileImage: user.profilePictureURL, userExercisePreferences: user.exercisePreferences, userSocialLink: user.userSocialLink)
  15. }
  16. }
  17. }
  18. .padding(.top, 15) // &lt;&lt; add separation from list and search bar
  19. // .navigationBarTitle(&quot;Search&quot;) // &lt;- remove this
  20. //SEARCH
  21. .searchable(text: $userSearch ,placement: .navigationBarDrawer(displayMode: .always), prompt: &quot;Search by gender, height or weight&quot;) // &lt;&lt; always display search bar
  22. .disableAutocorrection(true) // &lt;&lt; disable autocorrect
  23. .frame(maxWidth: .infinite, maxHeight: .infinite) // &lt;- this is important to add at the top container View of your content
  24. }
  25. }
  26. .navigationViewStyle(StackNavigationViewStyle()) // &lt;&lt; for ipad styling

huangapple
  • 本文由 发表于 2023年4月6日 21:03:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/75949851.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定