【发布时间】:2019-07-01 14:02:56
【问题描述】:
我有一个页面控制器,我在其中添加了 UIViewControllers 并在每个视图控制器中显示一堆表单。我现在面临的问题是我需要获取每个表单中提供的数据并保存它,这是在最后一个视图控制器中完成的。我曾尝试使用委托,但在单击下一个按钮的那一刻,之前存储的值变为nil,并且只显示最新的VC 的值。如何在此文本字段中传递数据。如有任何帮助,将不胜感激。
我的代表
protocol NextDelegate: AnyObject {
func next(pageIndex: Int, model: CreatePropertyModel)
func previous(pageIndex: Int, model: CreatePropertyModel)
}
我如何创建 VC 数组
lazy var controllers: [UIViewController] = {
let descVC = DescVC()
descVC.delegate = self
let priceVC = PriceVC()
priceVC.delegate = self
let featuresVC = FeaturesVC()
featuresVC.delegate = self
let picturesVC = PicturesVC()
picturesVC.delegate = self
return [descVC, priceVC, featuresVC, picturesVC]
}()
模型示例
class CreatePropertyModel: DictionaryEncodable {
var title: String?
var desc: String?
var property_type_id: Int?
var property_sub_type_id: Int?
var location_id: Int?
var currency: String?
var price: Int?
}
【问题讨论】:
标签: ios swift uipagecontrol