首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在call SwiftUI中位置#11,#12处的额外参数

在call SwiftUI中位置#11,#12处的额外参数
EN

Stack Overflow用户
提问于 2020-07-09 17:31:27
回答 1查看 11.7K关注 0票数 25

我继续在SwiftUI中的切换开关上得到一个“在第11位,第12位的额外参数”错误。我见过其他人有“电话中的额外论点”错误,但答案似乎没有帮助;此外,我的错误说“第11,12位”,这是我从未见过的其他人。我正在使用Xcode 12测试版,如果这有区别的话。

代码语言:javascript
复制
import SwiftUI

let defaults = UserDefaults.standard

let notifsEnabled = defaults.bool(forKey: "NotifsEnabled")




struct Settings: View {
    @State var class11: String = defaults.string(forKey: "class11") ?? ""
    @State var class12: String = defaults.string(forKey: "class12") ?? ""
    @State var class13: String = defaults.string(forKey: "class13") ?? ""
    @State var class14: String = defaults.string(forKey: "class14") ?? ""
    
    @State var class21: String = defaults.string(forKey: "class21") ?? ""
    @State var class22: String = defaults.string(forKey: "class22") ?? ""
    @State var class23: String = defaults.string(forKey: "class23") ?? ""
    @State var class24: String = defaults.string(forKey: "class24") ?? ""
    
    @State var scheduleNotifications = notifsEnabled
    
    
    
    var body: some View {
        
        VStack(alignment: .leading) {
            
            Toggle(isOn: $scheduleNotifications) { //Extra arguments at positions #11, #12 in call
                Text("Daily schedule notifications")
            }
            
            if scheduleNotifications {
                Text(CreateNotifs())
            } else {
                Text(DeleteNotifs())
            }
            
            
            
            Text("This App will send you a reminder each day at 8:25 with the schedule for that day")
                .font(.caption)
                .foregroundColor(Color.gray)
            
            
            Divider()
            
            TextField("Class 1-1", text: $class11)
            
            TextField("Class 1-2", text: $class12)
            
            TextField("Class 1-3", text: $class13)
            
            TextField("Class 1-4", text: $class14)
            
            TextField("Class 2-1", text: $class21)
            
            TextField("Class 2-2", text: $class22)
            
            TextField("Class 2-3", text: $class23)
            
            TextField("Class 2-4", text: $class24)
            
            
            
            //Spacer()
        }
        .padding()
        .navigationBarTitle("Settings")
        
    }
    
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-09 17:37:39

ViewBuilder只支持一个容器中最多10个静态视图.这是你犯错的原因之一

把他们分组

代码语言:javascript
复制
Group {

    TextField("Class 1-1", text: $class11)
    
    TextField("Class 1-2", text: $class12)
    
    TextField("Class 1-3", text: $class13)
    
    TextField("Class 1-4", text: $class14)
    
    TextField("Class 2-1", text: $class21)
    
    TextField("Class 2-2", text: $class22)
    
    TextField("Class 2-3", text: $class23)
    
    TextField("Class 2-4", text: $class24)

}
票数 76
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62820488

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档