Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios tableview swift 3中的不同单元格_Ios_Swift_Xcode_Uitableview - Fatal编程技术网

Ios tableview swift 3中的不同单元格

Ios tableview swift 3中的不同单元格,ios,swift,xcode,uitableview,Ios,Swift,Xcode,Uitableview,示例[1]: 如何正确制作下表 我不要拐杖 除X.count块外,所有单元格都会有一个不同的数字(两个或多个) 如何找出块X中的第一个和最后一个单元格,以显示或隐藏单元格之间的条带(在点之间,我制作了三个薄的条带,并希望根据单元格隐藏或显示单元格) 请出示你的护照code@Lalitkumar为什么你强制展开一个可选的,然后把它扔到一个可选的?这太荒谬了。@vadian现在这并不重要,我问的是cell和tableview import UIKit import CoreLocation imp

示例[1]:

  • 如何正确制作下表 我不要拐杖 除X.count块外,所有单元格都会有一个不同的数字(两个或多个)

  • 如何找出块X中的第一个和最后一个单元格,以显示或隐藏单元格之间的条带(在点之间,我制作了三个薄的条带,并希望根据单元格隐藏或显示单元格)



  • 请出示你的护照code@Lalitkumar为什么你强制展开一个可选的,然后把它扔到一个可选的?这太荒谬了。@vadian现在这并不重要,我问的是cell和tableview
    import UIKit
    import CoreLocation
    import Alamofire
    import SwiftyJSON
    
    
    class TableVC: UIViewController,UITableViewDelegate, UITableViewDataSource {
    
        @IBOutlet weak var tableView: UITableView!
    
        @IBOutlet weak var loadingView: UIView!
    
    
        var number: String! = "number"
    
        var detail_data: DetailListData?
    
    
    
    
    
    
    
        var token: String?
        var json = "Invalid"
    
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
    
            loadingView.isHidden = false
    
            print("===============================",number!)
    
            tableView.register(UINib(nibName: "HeaderTVC", bundle: Bundle.main), forCellReuseIdentifier: "HeaderTVC")
            tableView.register(UINib(nibName: "DistanceTVC", bundle: Bundle.main), forCellReuseIdentifier: "DistanceTVC")
            tableView.register(UINib(nibName: "MapTVC", bundle: Bundle.main), forCellReuseIdentifier: "MapTVC")
            tableView.register(UINib(nibName: "InfoTVC", bundle: Bundle.main), forCellReuseIdentifier: "InfoTVC")
            tableView.register(UINib(nibName: "BottomTVC", bundle: Bundle.main), forCellReuseIdentifier: "BottomTVC")
    
            tableView.delegate = self
    
            token = UserDefaults.standard.value(forKey: "token")! as? String
    
            getData()
        }
    
        func getData () {
    
            let httpHeaders = ["Authorization": token!,
                               "Accept": "application/json"]
    
            Alamofire.request(REST_API.MAIN_URL_DEV + REST_API.SHIPMENTS + "/" + number! ,encoding: JSONEncoding.default, headers: httpHeaders)
                .responseString { response in
    
                    if let JSON = response.result.value {
                        self.json = JSON
    
                        //                    print(JSON)
    
                        if let jsonObj = self.json.parseJSONString {
    
                            if let data = jsonObj as? NSDictionary {
    
                                if let obj = DetailListJson4Swift_Base(dictionary: data) {
    
    
                                    if obj.status?.code == 200 {
    
                                        self.detail_data = obj.data
    
    
                                        print("////====================  DATA", obj.data!, self.detail_data!)
    
    
                                        self.loadingView.isHidden = true
    
                                        self.tableView.reloadData()
    
    
                                    } else {
    
                                        print("Status: Error code")
                                        MyAlertController.doAlert("Error", alertMessage: "something wrong, try again late")
                                    }
    
                                } else {
                                    MyAlertController.doAlert("Error", alertMessage: "Unable to construct movie object")
                                    print("Unable to construct movie object")
                                }
    
                            } else {
                                MyAlertController.doAlert("Error", alertMessage: "Unable to interpret parsed object as dictionary")
                                print("Unable to interpret parsed object as dictionary")
                                print(jsonObj)
                            }
                        }
                    }
            }
        }
    
        @IBAction func accept(_ sender: Any) {
    
    
        }
    }
    
    
    extension TableVC {
    
    
        func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    
            if detail_data != nil {
    
                if section == 0 {
    
                    return 3
    
                } else if section == 1 {
    
    
                    return (detail_data?.waypoints?.count)!
                } else if section == 2 {
    
    
                    return 1
                }
    
            }
            return 0
        }
    
        func numberOfSections(in tableView: UITableView) -> Int {
    
            return 2
        }
    
        func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    
    
            if indexPath.row == 0 {
    
                let headerTVC = tableView.dequeueReusableCell(withIdentifier: "HeaderTVC", for: indexPath) as! HeaderTVC
    
                headerTVC.code.text = detail_data?.id!
                headerTVC.price.text = detail_data?.price?.total!
                headerTVC.distamce.text = detail_data?.distance!
                return headerTVC
    
            }
    
    
            if indexPath.row == 1 {
    
                let distanceTVC = tableView.dequeueReusableCell(withIdentifier: "DistanceTVC", for: indexPath) as! DistanceTVC
    
    
    
                return distanceTVC
            }
    
            if indexPath.row == 2 {
    
                let mapTVC = tableView.dequeueReusableCell(withIdentifier: "MapTVC", for: indexPath) as! MapTVC
    
    
                return mapTVC
            }
    
            if indexPath.row == 4 {
    
                let bottomTVC = tableView.dequeueReusableCell(withIdentifier: "BottomTVC", for: indexPath) as! BottomTVC
    
    
    
                return bottomTVC
            }
    
    
    
            // the other cells should contains title and subtitle:
            let infoTVC = tableView.dequeueReusableCell(withIdentifier: "InfoTVC", for: indexPath) as! InfoTVC
    
    
            return infoTVC
        }
    
        func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
            return UITableViewAutomaticDimension
        }
    
        func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
            return UITableViewAutomaticDimension
        }