动态初始化UIViewController子类并创建其实例

时间:2016-02-22 13:20:38

标签: ios iphone swift uiviewcontroller

我正在尝试建立一个简单的车辆管理应用程序,作为我大学任务的一部分。如果我的查询过于基本,因为我不熟悉编程,我会提前道歉。 所以,问题是

  1. 如何初始化 UIViewController 子类动态
  2. 用户在 UITextField 栏中的不同故事板场景中输入我的所有变量,并通过 prepareForSegue() func
  3. 传递给下一个类
  4. 我想在每次用户输入新车辆的数据时创建一辆新车,然后我想在故事板 TableViewController 子类场景中的所有车辆。< / LI>

    非常感谢您的帮助。请考虑我想要为其创建实例的子类的屏幕截图。

    谢谢和问候 Final Sub Class which is to be dynamically instantiated

    class SelectVehicleViewController: UIViewController, UITableViewDelegate
    {   
    var vehName = String()
    var vehVIN = String()
    var engineType = String()
    var engineCapacity = String()
    var manufacturingYear = String()
    var odometerDistance = Int()
    
    var engineOil = Int()
    var transmissionOil = Int()
    var powerSteeringOil = Int()
    var brakeOil = Int()
    var coolant = Int()
    var engineAirFilter = Int()
    var engineOilFilter = Int()
    var fuelFilter = Int()
    var fuelInjectors = Int()
    var cabinAirFilter = Int()
    var timingBelt = Int()
    var accessoryBelt = Int()
    
    var setupLastRefuelling = Int()
    
    init(vehName: String, vehVIN: String, engineType: String, engineCapacity: String, manufacturingYear: String, odometerDistance: Int,
        engineOil: Int, transmissionOil: Int, powerSteeringOil: Int, brakeOil: Int, coolant: Int, engineAirFilter: Int, engineOilFilter: Int,
        fuelFilter: Int, fuelInjectors: Int, cabinAirFilter: Int, timingBelt: Int, accessoryBelt: Int,‹ setupLastRefuelling: Int)
    {
    
    }
    
    required init?(coder aDecoder: NSCoder)
    {
        fatalError("init(coder:) has not been implemented")
    }
    // Create an object of the data received from Summary Scene in SelectVehicle Scene
    
    //var vehicleArray: [SelectVehicleViewController] = []
    
    override func viewDidLoad()
    {
        super.viewDidLoad()
    }
    
        //Setting up the table view in Vehicle Selector Scene
    
     //    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
    { return vehicleArray.count}
    
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
    {
        let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "cell")
    
        //cell.textLabel?.text = vehicleArray[indexPath.row]
    
        return cell
    }
    
    
    override func didReceiveMemoryWarning()
    {
        super.didReceiveMemoryWarning()
    }
    }
    

0 个答案:

没有答案