任何人帮我解决这个问题
我在视图中有多个按钮...当我点击按钮时我需要调用多个阵列的同一个表...我怎么能在这里做到这一点我必须使用唯一一个表任何一个帮助解决这个问题
提前致谢
这是我的代码
@IBAction func CountrySelectDropDown(_ sender: Any) {
if(CountryBoolean == false){
self.Popup_view.isHidden = false
CountryBoolean = true
StateBoolean = false
CityBoolean = false
self.tableview.reloadData()
}
else{
self.Popup_view.isHidden = true
CountryBoolean = false
}
}
@IBAction func State_DropDwon_Touch(_ sender: Any) {
if(StateBoolean == true){
self.Popup_view.isHidden = false
CountryBoolean = false
StateBoolean = true
CityBoolean = false
self.tableview.reloadData()
}
else{
self.Popup_view.isHidden = true
StateBoolean = false
}
}
@IBAction func City_DropDown_Touch(_ sender: Any) {
if(CityBoolean == true){
self.Popup_view.isHidden = false
CountryBoolean = false
StateBoolean = false
CityBoolean = true
self.tableview.reloadData()
}
else{
self.Popup_view.isHidden = true
CityBoolean = false
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// Return the number of items in the sample data structure.
var count:Int?
if(CountryBoolean == false) {
count = CoutryArray.count
}
if(StateBoolean == true) {
count = StateArray.count
}
if(CityBoolean == true) {
if (self.resultSearchController.isActive) {
return self.filteredTableData.count
}
else {
return self.reponseArray.count
}
}
return count!
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell:UITableViewCell?
cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath as IndexPath)
if(CountryBoolean == false) {
cell?.layer.borderWidth = 1.0
cell?.layer.borderColor = UIColor(red:223/255.0, green:44/255.0, blue:51/255.0, alpha: 1.0).cgColor
cell?.textLabel?.adjustsFontSizeToFitWidth = true
cell?.textLabel?.font = UIFont(name:"Avenir", size:13)
var CountryDict = CoutryArray[indexPath.row]
cell!.textLabel!.text = CountryDict["countryName"] as? String
}
if(StateBoolean == true) {
var StateDict = StateArray[indexPath.row]
cell!.textLabel!.text = StateDict["name"] as? String
}
}