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

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

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.

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

答案1

得分: 1

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

NavigationView {
    VStack {
        HStack {
            // 这是您的导航栏
            Text("Your Title")
                .padding()
        }
        VStack {
            // 这里放置所有您的内容...
        }
        .frame(maxWidth: .infinity, maxHeight: .infinity) // <- 添加这一行
    }
}
.navigationViewStyle(StackNavigationViewStyle())

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

NavigationView {
    VStack {
        // 这是您的导航栏
        HStack {
            Text("Search")  // <- 您的标题在此
                .padding()
        }

        // 将所有视图内容放在这里 - 下面

        // 显示用户
        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")

        // 搜索
        .searchable(text: $userSearch, placement: .navigationBarDrawer(displayMode: .always), prompt: "Search by gender, height or weight")
        .disableAutocorrection(true)
        .frame(maxWidth: .infinite, maxHeight: .infinite)
    }
}
.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:

NavigationView {
    VStack {
        HStack {
            // this is your navigation bar
            Text(&quot;Your Title&quot;)
                .padding()
        }
        VStack {
            // all your contents here...
            
        }
        .frame(maxWidth: .infinity,maxHeight: .infinity) // &lt;- 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(&quot;Search&quot;)  // &lt;- 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) // &lt;&lt; add separation from list and search bar
        
//        .navigationBarTitle(&quot;Search&quot;) // &lt;- remove this
        
        //SEARCH
        .searchable(text: $userSearch ,placement: .navigationBarDrawer(displayMode: .always), prompt: &quot;Search by gender, height or weight&quot;) // &lt;&lt; always display search bar
        .disableAutocorrection(true) // &lt;&lt; disable autocorrect
        
        .frame(maxWidth: .infinite, maxHeight: .infinite)   // &lt;- this is important to add at the top container View of your content
        
    }
}
.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:

确定