如何在SwiftUI上创建/使用\ .Identifier?

问题描述 投票:0回答:1

我已经使用pod创建分页滚动:

https://github.com/fermoya/SwiftUIPager

但是,有些错误描述得不够充分。

UI

  1. 我已创建

    struct ContentView: View {
        @State private var page = 0
        ...
    }
    
  2. self.levels = ["img1", "img2"...]

    3。

    struct cardView: View {
    
    var item : String
    @Binding var page: Int
    let screenW = UIScreen.main.bounds.width
    let screenH = UIScreen.main.bounds.height
    let sceneButtonH = UIScreen.main.bounds.height * 0.6494
    let sceneButtonW = (UIScreen.main.bounds.height * 0.6494) * 1.0867
    let buttonPadding = ((UIScreen.main.bounds.height * 0.6494) * 1.0867) * 0.26
    
    var body: some View{
    
            Button(action: {
                //self.showingDetail.toggle()
            }) {
                Image(uiImage: UIImage(named: item )!)
                    .renderingMode(.original)
                    .resizable()
                    .aspectRatio(contentMode: .fit)
                    .padding(.leading, buttonPadding/2)
                    .padding(.trailing, buttonPadding/2)
            }
    }
    
    }
    

如何创建.identifier?这是一个自定义方法?

swiftui pager
1个回答
1
投票

根据您的代码,假设self.level[String]。如果是,请尝试使用id:\ .self

谢谢!

© www.soinside.com 2019 - 2024. All rights reserved.