如何显示部分标题,已在Swift中退出部分

时间:2019-07-18 09:32:46

标签: ios arrays swift uitableview dictionary

我正在设置UITableview的部分。我创建的numberofrowinsection取决于JSON数据计数。现在,我要设置已退出部分中的另一部分?

     func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {

           if (section == 0) {
               return ""
           }
           else  if(section == 1 ) { //&& self.contactFormResponse.count>0
               return ""
           }
           else if section == numberOfSections-1 {
               if isMSDivPrtyChecking == true {
                  //dictionary key title after hit server
               }
               else {
                       return  ""
               }
           }
               //multishare
           else if (section == numberOfSections-2){
               return ""
           }
           else if(section == numberOfSections-3){ //1
               return ""
           }
    JSON:     {
    "statusCode": 200,
    "statusMessage": "success",
    "response": {
        "data": {
            "Div 1": [
                {
                    "ID": "6",
                    "Value": "H1",
                },
                {
                    "ID": "7",
                    "Value": "L1",
                },
                {
                    "ID": "20",
                    "Value": "ManageP1",
                },
                {
                    "ID": "21",
                    "Value": "ManagerP2",
                }
            ],
            "Div2": [
                {
                    "ID": "10",
                    "Value": "Cool"

                },
                {
                    "ID": "11",
                    "Value": "Warm"
                }
            ]
        }
    }}

    fileprivate  var msDivPrtySection = Array<DivPrioritySection>()

我在代码下方实现了JSON响应:

 if let Streams = responseDict["response"] as? [String:AnyObject]
                {
                    let dictArrayDict = Streams["data"] as! Dictionary<String,AnyObject>
                        //as? [String:AnyObject] {
                       self.divPrityRowsCount = dictArrayDict.count

                    for (key, value) in dictArrayDict {

                        let users = DivPrioritySection(divisionName: key, data: value as! Array<Dictionary<String, String>>)

                        self.msDivPrtySection.append(users)
                    }

在这里,我在表格视图Total numberOfSections = 5中安顿下来,当我点击服务器时,isMSDivPrtyChecking将在上面的JSON中返回字典数组。我想在

中显示特定部分内部的字典关键字名称
else if section == numberOfSections-1 {
        if isMSDivPrtyChecking == true {
      // Here displaying JSON arrayOfDictionary title (dictionary key names)
        }

我根据json数据计数创建了numberofrowinsection,还通过JSON单个DIV1,DIV2等对按钮操作进行了下拉。

0 个答案:

没有答案
相关问题