大佬教程收集整理的这篇文章主要介绍了ios – 使用MultivaluedSection的奇怪行为?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经使用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 } }
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添加一些人时,标题没有左对齐,为什么:
非常感谢!
以上是大佬教程为你收集整理的ios – 使用MultivaluedSection的奇怪行为?全部内容,希望文章能够帮你解决ios – 使用MultivaluedSection的奇怪行为?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。