Ich habe eine Tableview, die Wie zeigt man die Anzahl der Zeilen im Abschnitt nach dem Tippen auf Abschnitt Kopfzeile in Swift?
einige
enthalten aber ich will es nur Abschnittsheader zeigen, und wenn ich auf Abschnitt Kopf tippen wird es alle Mitarbeiterdaten zeigen nur diesen Abschnitt contining.
Unten ist mein Code:
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return company.count
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return company[section].employees!.count
}
func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
if company[section].employees!.count < 1 {
return nil
}
return company[section].companyName
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell") as! EmployeeTableViewCell
let employeeDetails = company[indexPath.section].employees!.allObjects as! [Employees]
cell.lblName.text = employeeDetails[indexPath.row].employeeName
cell.lblAddress.text = String(employeeDetails[indexPath.row].address!)
cell.lblAge.text = String(employeeDetails[indexPath.row].age!)
return cell
}
Dank!
Ich habe mySelected Array wie folgt deklariert: var selectedArray: NSMutableArray! und ich bekomme einen Absturz beim Tippen auf Abschnittsüberschrift in dieser Zeile if (selectedArray.containsObject (sender.tag)) { –
deklarieren Array wie folgt var selectedArray: NSMutableArray = [] –
@ S.Barti Ich habe eine Zeile in selectedSectionStoredButtonClicked Check hinzugefügt es. Wenn Sie dies auskommentieren als andere Abschnitt wird Zeile ausblenden –