Commit ac3312fd authored by David黄金龙's avatar David黄金龙

处理 一处文件加载的问题

parent 27909f43
......@@ -243,6 +243,7 @@
A510441A2B495DD0006B60BB /* UIView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51044192B495DD0006B60BB /* UIView+Extension.swift */; };
A514E5DC2B60A2B700C93951 /* YHServiceCenterSecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A514E5DB2B60A2B700C93951 /* YHServiceCenterSecondViewController.swift */; };
A525D2302BA83B87001A84F5 /* YHFileListBottomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A525D22F2BA83B87001A84F5 /* YHFileListBottomView.swift */; };
A528253A2BA9B49200CB9F40 /* area.plist in Resources */ = {isa = PBXBuildFile; fileRef = A52825392BA9B49200CB9F40 /* area.plist */; };
A53026902B4E6F2700F35102 /* YHHomeCustomCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A530268F2B4E6F2700F35102 /* YHHomeCustomCell.swift */; };
A554A5122B99715000EA5973 /* YHConstantArrayData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A554A5112B99715000EA5973 /* YHConstantArrayData.swift */; };
A5551FFE2B4C26CE00510980 /* YHBaseViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5551FFD2B4C26CE00510980 /* YHBaseViewModel.swift */; };
......@@ -617,6 +618,7 @@
A51044192B495DD0006B60BB /* UIView+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Extension.swift"; sourceTree = "<group>"; };
A514E5DB2B60A2B700C93951 /* YHServiceCenterSecondViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHServiceCenterSecondViewController.swift; sourceTree = "<group>"; };
A525D22F2BA83B87001A84F5 /* YHFileListBottomView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFileListBottomView.swift; sourceTree = "<group>"; };
A52825392BA9B49200CB9F40 /* area.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = area.plist; sourceTree = "<group>"; };
A530268F2B4E6F2700F35102 /* YHHomeCustomCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeCustomCell.swift; sourceTree = "<group>"; };
A554A5112B99715000EA5973 /* YHConstantArrayData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHConstantArrayData.swift; sourceTree = "<group>"; };
A5551FFD2B4C26CE00510980 /* YHBaseViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHBaseViewModel.swift; sourceTree = "<group>"; };
......@@ -1358,6 +1360,7 @@
045EEE6A2B9F171A0022A143 /* YHAddressPicker */ = {
isa = PBXGroup;
children = (
A52825392BA9B49200CB9F40 /* area.plist */,
045EEE6C2B9F171A0022A143 /* YHAddressModel.swift */,
045EEE6D2B9F171A0022A143 /* YHAddressViewController.swift */,
045EEE6E2B9F171A0022A143 /* YHAddressPickViewTableViewCell.swift */,
......@@ -2106,6 +2109,7 @@
A51044182B493675006B60BB /* README.md in Resources */,
A5573EDB2B317C0000D98EC0 /* Assets.xcassets in Resources */,
A5E69D512BA304D400411932 /* DIN Alternate Bold.ttf in Resources */,
A528253A2BA9B49200CB9F40 /* area.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -49,7 +49,7 @@ class YHAddressPickView: UIView {
// self.underLine.center = CGPoint(x: self.buttonArr[1].center.x, y: self.underLine.center.y)
self.dataArray = locationModel?.provincesArray.map({ model in
model.provincesName
})
}) ?? []
self.tableView.reloadData()
case .city:
/// 选择城市时没有热门城市view,并将titleSV显示出来
......@@ -77,7 +77,7 @@ class YHAddressPickView: UIView {
})
self.dataArray = provincesModel?.cityArray.map({ model in
model.cityName
})
}) ?? []
self.tableView.reloadData()
}
}
......@@ -110,7 +110,7 @@ class YHAddressPickView: UIView {
/// 城市数据
private var cityModel: YHCityModel?
/// 当前tableView使用的数据源
private var dataArray: [String]?
private var dataArray: [String] = []
private let titleLabel: UILabel = {
let label = UILabel(frame: CGRect(x: (UIScreen.main.bounds.width - 150) / 2, y: 16, width: 150, height: 24))
label.textColor = UIColor.mainTextColor
......@@ -291,10 +291,15 @@ class YHAddressPickView: UIView {
/// 从area.plist获取全部地区数据
private func initLocationData() {
guard let dic = NSDictionary(contentsOfFile: Bundle.main.path(forResource: "area", ofType: "plist") ?? "") as? [String:[String]] else {
locationModel = nil
dataArray = []
return
}
locationModel = YHCountryModel(dic: dic)
dataArray = locationModel?.provincesArray.map({$0.provincesName})
if let model = locationModel {
dataArray = model.provincesArray.map({$0.provincesName})
}
}
}
// MARK: - tableViewDelegate
......@@ -303,7 +308,7 @@ extension YHAddressPickView: UITableViewDelegate,UITableViewDataSource {
return 40
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return (self.dataArray?.count)! + 1
return self.dataArray.count + 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == 0 {
......@@ -316,7 +321,7 @@ extension YHAddressPickView: UITableViewDelegate,UITableViewDataSource {
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHAddressPickViewTableViewCell.identifier) as? YHAddressPickViewTableViewCell else {
return YHAddressPickViewTableViewCell()
}
cell.label.text = self.dataArray?[indexPath.row - 1]
cell.label.text = self.dataArray[indexPath.row - 1]
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment