Error[8]: Undefined offset: 3, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述) 我已经使用Eureka一段时间了,太棒了! 最近我在使用MultivaluedSection,我编写了一个简单的测试项目:它简单地从tableView添加/删除人. 这里是代码,首先是模型:Person struct Person:Equatable,CustomStringConvertible{ var description: String{ return "\( )

我已经使用Eureka一段时间了,太棒了!

最近我在使用MultivaluedSection,我编写了一个简单的测试项目:它简单地从tableVIEw添加/删除人.

这里是代码,首先是模型:Person

struct Person:Equatable,customstringconvertible{    var description: String{        return "\(name) \(ID)"    }    static func ==(lhs: Person,rhs: Person) -> Bool {        return lhs.ID == rhs.ID    }    var ID:String    var name:String    init(name:String){        self.ID = UUID().uuIDString        self.name = name    }}

VC的下一个代码:

class VIEwController: FormVIEwController {    var people:[Person] = []    overrIDe func vIEwWillAppear(_ animated: Bool) {        super.vIEwWillAppear(animated)        //hIDe delete button at row left        tableVIEw.isEditing = false    }    overrIDe func vIEwDIDLoad() {        super.vIEwDIDLoad()        let peopleSection = MultivaluedSection(multivaluedOptions:[.Delete,.Reorder,.Insert],header:"people")        peopleSection.tag = "people"        peopleSection.multivaluedRowToInsertAt = {IDx in            let newRow = LabelRow(){row in                let person = Person(name: "h\(IDx)")                row.value = person.description                self.people.append(person)                let deleteAction = SwipeAction(style: .destructive,Title: "DEL"){action,row,completion in                    completion?(true)                }                row.trailingSwipe.actions = [deleteAction]            }            return newRow        }        peopleSection.addbuttonProvIDer = {section in            let addBtn = buttonRow("add"){row in                row.Title = "new person"            }            return addBtn        }        form +++ peopleSection    }}

运行应用程序,如下图所示:

有两个问题:

1:你可以看到我添加3个人然后按顺序删除它们,一切都很好!但是,当我再次添加一个人时,发生了一些错误:似乎该部分的标题被拉得很长.为什么???

2:当我向tableVIEw添加一些人时,标题没有左对齐,为什么:

非常感谢!

解决方法 请更新代码,

peopleSection.multivaluedRowToInsertAt = {IDx in    return LabelRow() {        let person = Person(name: "h\(IDx)")        [+++].Title = person.description        self.people.append(person)    }}

它将为您提供以下输出,删除也将正常工作.

总结

以上是内存溢出为你收集整理的ios – 使用MultivaluedSection的奇怪行为?全部内容,希望文章能够帮你解决ios – 使用MultivaluedSection的奇怪行为?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
ios – 使用MultivaluedSection的奇怪行为?_app_内存溢出

ios – 使用MultivaluedSection的奇怪行为?

ios – 使用MultivaluedSection的奇怪行为?,第1张

概述) 我已经使用Eureka一段时间了,太棒了! 最近我在使用MultivaluedSection,我编写了一个简单的测试项目:它简单地从tableView添加/删除人. 这里是代码,首先是模型:Person struct Person:Equatable,CustomStringConvertible{ var description: String{ return "\( )

我已经使用Eureka一段时间了,太棒了!

最近我在使用MultivaluedSection,我编写了一个简单的测试项目:它简单地从tableVIEw添加/删除人.

这里是代码,首先是模型:Person

struct Person:Equatable,customstringconvertible{    var description: String{        return "\(name) \(ID)"    }    static func ==(lhs: Person,rhs: Person) -> Bool {        return lhs.ID == rhs.ID    }    var ID:String    var name:String    init(name:String){        self.ID = UUID().uuIDString        self.name = name    }}

VC的下一个代码:

class VIEwController: FormVIEwController {    var people:[Person] = []    overrIDe func vIEwWillAppear(_ animated: Bool) {        super.vIEwWillAppear(animated)        //hIDe delete button at row left        tableVIEw.isEditing = false    }    overrIDe func vIEwDIDLoad() {        super.vIEwDIDLoad()        let peopleSection = MultivaluedSection(multivaluedOptions:[.Delete,.Reorder,.Insert],header:"people")        peopleSection.tag = "people"        peopleSection.multivaluedRowToInsertAt = {IDx in            let newRow = LabelRow(){row in                let person = Person(name: "h\(IDx)")                row.value = person.description                self.people.append(person)                let deleteAction = SwipeAction(style: .destructive,Title: "DEL"){action,row,completion in                    completion?(true)                }                row.trailingSwipe.actions = [deleteAction]            }            return newRow        }        peopleSection.addbuttonProvIDer = {section in            let addBtn = buttonRow("add"){row in                row.Title = "new person"            }            return addBtn        }        form +++ peopleSection    }}

运行应用程序,如下图所示:

有两个问题:

1:你可以看到我添加3个人然后按顺序删除它们,一切都很好!但是,当我再次添加一个人时,发生了一些错误:似乎该部分的标题被拉得很长.为什么???

2:当我向tableVIEw添加一些人时,标题没有左对齐,为什么:

非常感谢!

解决方法 请更新代码,

peopleSection.multivaluedRowToInsertAt = {IDx in    return LabelRow() {        let person = Person(name: "h\(IDx)")        .Title = person.description        self.people.append(person)    }}

它将为您提供以下输出,删除也将正常工作.

总结

以上是内存溢出为你收集整理的ios – 使用MultivaluedSection的奇怪行为?全部内容,希望文章能够帮你解决ios – 使用MultivaluedSection的奇怪行为?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1033244.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存