// // EngInfoDetailViewController.swift // Esay Project // //由Apple于26/11/18创建 . //版权所有©2018 apple . 版权所有 . // import UIKit类EngInfoDetailViewController:BaseViewController,UITableViewDelegate,UITableViewDataSource {var tableView:UITableView = UITableView()
var categoryDict:NSDictionary = NSDictionary()
var tableArray:NSArray = NSArray()
var selectedIndexPath:Int?

var GOIItemNames:String?
var GOINamesArray:[String] = []

var mainTitleString:String?
var mainTitleLabel = UILabel()
var mainTitleString1:[String] = []

override func viewDidLoad(){
super.viewDidLoad()
createNavigationBar(navigationTitle:kNavigationTitleEngineersInfo,imageString:
kImageMenuHomeIcon,showLeftButton:true)createUI()} func createUI()
{
tableArray = categoryDict.object(forKey:“submenudata”)as? NSArray ?? . 在里面()

let backgroundIV = createImageViewWithRect(setFrame:CGRect(x:0.0,y:0.0,width:screenWidth,height:screenHeight),
imageString:kImageBackground)self.view.addSubview(backgroundIV)let searchTF = createTextFieldWithRect(setFrame:CGRect(x:screenWidth * 7.0 / 100.0,y:screenHeight * 12.0 / 100.0,width:screenWidth * 85.0 / 100.0,height:screenHeight * 6.0 /100.0),backgroundColor:
mainGrayColor,borderColor:.black,borderWidth:0.5,cornerRadius:0.0,textString:“”)searchTF.layer.cornerRadius = searchTF.frame.size.height / 2.0 searchTF.attributedPlaceholder = NSAttributedString(string:“SAMPLE TEXT”,属性: [NSAttributedString.Key.foregroundColor:mainYellowColor])//在左边创建填充的填充视图
searchTF.leftView = UIView(frame:CGRect(x:0,y:0,width:15,height:searchTF.frame.height))
searchTF.leftViewMode = .always

//在右侧创建填充的填充视图
searchTF.rightView = UIView(frame:CGRect(x:0,y:0,width:searchTF.frame.size.width * 33.0 / 100.0,height:searchTF.frame.height))
searchTF.rightViewMode = . 始终
searchTF.textColor = mainYellowColor
self.view.addSubview(searchTF)

let searchButton = createButtonWithFrame(setFrame:CGRect(x:searchTF.frame.size.width * 70.0 / 100.0,y:0.0,width:searchTF.frame.size.width * 30.0 / 100.0,height:searchTF.frame.size.height )的backgroundColor:mainYellowColor,buttonText: “搜索”,buttonTextColor: . 黑,titleFont:UIFont(名称:
kFontQanDemoBold,大小:18.0)!)searchButton.layer.cornerRadius = searchButton.frame.size.height / 2.0 //searchButton.addTarget(self,action:#selector(searchButtonClicked),for:.touchUpInside)searchTF.addSubview(searchButton) let headerView = createViewWithFrame(setFrame:CGRect(x:screenWidth * 15.0 / 100.0,y:searchTF.frame.origin.y searchTF.frame.size.height screenHeight * 10.0 / 100.0,width:screenWidth * 70.0 / 100.0,height:screenHeight * 8.0 / 100.0),backgroundColor:mainGrayColor)
headerView.layer.cornerRadius = headerView.frame.size.height / 2.0
self.view.addSubview(headerView)

让headerString = categoryDict.object(forKey:“maintitle”)为!串

let headerLabel = createLabelWithFrame(setFrame:CGRect(x:headerView.frame.size.width * 1.5 / 100.0,y:headerView.frame.size.height * 7.0 / 100.0,width:headerView.frame.size.width * 97.0 / 100.0 ,身高:headerView.frame.size.height * 85.0 / 100.0),
backgroundcolor:.clear,labeltext:headerString,labelFont:UIFont(name:kFontQanDemoBold,size:17.0)!,textColor:mainYellowColor,textAlignment:.center)headerLabel.layer.borderColor = mainYellowColor.cgColor
headerLabel.layer.borderWidth = 1.5
headerLabel.layer.cornerRadius = headerLabel.frame.size.height / 2.0
headerLabel.clipsToBounds = true
headerView.addSubview(headerLabel)

让displayTable = categoryDict.object(forKey:“submenu”)为!串
if(displayTable ==“1”)
{
tableView = createTableView(setFrame:CGRect(x:0.0,y:headerView.frame.origin.y headerView.frame.size.height screenHeight * 6.0 / 100.0,width:screenWidth,height:screenHeight * 57.0 / 100.0),
backgroundColor:.clear)tableView.delegate = self tableView.dataSource = self tableView.separatorStyle = UITableViewCell.SeparatorStyle.none self.view.addSubview(tableView)}} // MARK:TableView委托方法
func tableView(_ tableView:UITableView,numberOfRowsInSection section:Int) - > Int {
return tableArray.count

}

func tableView(_ tableView:UITableView,cellForRowAt indexPath:IndexPath) - > UITableViewCell {

tableView.register(UITableViewCell.self,forCellReuseIdentifier:“Cell”)

let cell = tableView.dequeueReusableCell(withIdentifier:“Cell”,for:indexPath)
cell.selectionStyle = .none
cell.backgroundColor = .clear

让innerDict = tableArray [indexPath.row]为!的NSDictionary
mainTitleString = innerDict.object(forKey:“maintitle”)as!串
mainTitleString1.append(mainTitleString!)
// print(mainTitleString1)

mainTitleLabel = createLabelWithFrame(setFrame:CGRect(x:0.0,y:cell.frame.size.width * 2.0 / 100.0,width:cell.frame.size.width,height:screenHeight * 8.0 / 100.0),backgroundcolor:mainGrayColor,labeltext :mainTitleString !,
labelFont:UIFont(名称:kFontQanDemoBold,size:20.0)!,textColor:mainYellowColor,textAlignment:.center)mainTitleLabel.layer.cornerRadius = mainTitleLabel.frame.size.height / 2.0 mainTitleLabel.clipsToBounds = true cell.addSubview(mainTitleLabel)// let subTitleStringArray = innerDict . 对象(forKey:“submenudata”)as!任何
if mainTitleString ==“GOI - Build 细则”
{
if let item = innerDict [“submenudata”] {
if item是[[String:String]] {
让itemTitle = item为! NSArray的

var Axisadded = 2.0
如果selectedIndexPath == indexPath.row
{
因为我在0 ... 4
{
让itemTitle1 = itemTitle [i]为!的NSDictionary

GOIItemNames = itemTitle1.object(forKey:“maintitle”)as!串
GOINamesArray.append(GOIItemNames!)

let subTitleButton = createButtonWithFrame(setFrame:CGRect(x:20.0,y:
mainTitleLabel.frame.origin.y mainTitleLabel.frame.size.height screenHeight * CGFloat(Axisadded)/100.0,width:screenWidth-40,height:screenHeight*5.0/100.0),backgroundColor:mainGrayColor,buttonText:GOINamesArray [i],buttonTextColor :mainYellowColor,titleFont:UIFont(名称:kFontQanDemoBold,大小:14.0)!)subTitleButton.layer.cornerRadius = mainTitleLabel.frame.size.height / 2.0 subTitleButton.clipsToBounds = true cell.addSubview(subTitleButton)Axisadded = 10 // print( GOIItemNames)
}
// print(innerDict)
}

如果item是[String] {else
打印(“我是数组”)
}
}
}
否则如果mainTitleString ==“Andhra Pradesh”
{
if let item = innerDict [“submenudata”] {
if item是[[String:String]] {
让itemTitle = item为! NSArray的

让itemTitle1 = itemTitle [0]为!的NSDictionary
让AndhraNames = itemTitle1.object(forKey:“maintitle”)为!串
//打印(AndhraNames)

// print(innerDict)

如果item是[String] {else
打印(“我是数组”)
}
}
}

让sizeImage = UIImage(命名为:kImageMenuHomeIcon)!
让arrowImage:UIImage? = UIImage(名称:kImageBoldRightArrow)? . withRenderingMode(.alwaysTemplate)
let imageButton = createButtonWithImage(setFrame:CGRect(x:mainTitleLabel.frame.size.width * 85.0 / 100.0,y:cell.frame.size.width * 5.5 / 100.0,width:sizeImage.size.width / 1.0,height:sizeImage .size.height / 1.0),backgroundColor:mainYellowColor,imageString:kImageBoldRightArrow)
imageButton.setImage(arrowImage,for: . normal)
imageButton.tintColor = mainGrayColor
imageButton.layer.cornerRadius = imageButton.frame.size.height / 2.0
imageButton.clipsToBounds = true
cell.addSubview(的ImageButton)

返回细胞
}

func tableView(_ tableView:UITableView,heightForRowAt indexPath:IndexPath) - > CGFloat
{
if(selectedIndexPath == indexPath.row)
{
返回screenHeight * 30.0 / 100.0
}
其他
{
返回screenHeight * 10.0 / 100.0
}
}

func tableView(_ tableView:UITableView,didSelectRowAt indexPath:IndexPath)
{

//已经选择了行,然后我们想要折叠单元格
if indexPath.row == selectedIndexPath
else {//否则,我们扩展该单元格
selectedIndexPath = indexPath.row
}

let indexPosition = IndexPath(row:indexPath.row,section:0)
tableView.reloadRows(at:[indexPosition],with:.none)
}
}