Expandable Sections UITableView IndexPath SWIFT - swift

Im pretty new to coding, I only know Swift. I have found several tutorials to produce drop down sections in a table. Basically it will represent a TV show, the headers will be the seasons and the drop down list of episodes from each season.
I managed to get this working perfectly for what I want from https://github.com/fawazbabu/Accordion_Menu
This all looks good, however I need to be able to select from the drop down items. I have added didSelectRowAtIndexPath with just a simple print of the rows to start with. When I select a row, section or cell, random index paths are returned, the same row can be pressed a second time and return a different value. I thought this was just something I had added to the issue. So I added didSelectRowAtIndexPath to the original code. This has the same issue.
I assume this is because a UIGestureRecogniser is being used as well as didSelectRowAtIndexPath. But I am not sure what the alternative is.
Could someone tell me where I am going wrong please?
import UIKit
import Foundation
class test: UIViewController, UITableViewDelegate, UITableViewDataSource {
#IBOutlet var tableView: UITableView!
var sectionTitleArray : NSMutableArray = NSMutableArray()
var sectionContentDict : NSMutableDictionary = NSMutableDictionary()
var arrayForBool : NSMutableArray = NSMutableArray()
override func awakeFromNib() {
super.awakeFromNib()
tableView.delegate = self
tableView.dataSource = self
arrayForBool = ["0","0"]
sectionTitleArray = ["Pool A","Pool B"]
var tmp1 : NSArray = ["New Zealand","Australia","Bangladesh","Sri Lanka"]
var string1 = sectionTitleArray .objectAtIndex(0) as? String
[sectionContentDict .setValue(tmp1, forKey:string1! )]
var tmp2 : NSArray = ["India","South Africa","UAE","Pakistan"]
string1 = sectionTitleArray .objectAtIndex(1) as? String
[sectionContentDict .setValue(tmp2, forKey:string1! )]
self.tableView.registerNib(UINib(nibName: "CategoryNameTableCell", bundle: NSBundle.mainBundle()), forCellReuseIdentifier: "CategoryNameTableCell")
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return sectionTitleArray.count
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
if(arrayForBool .objectAtIndex(section).boolValue == true){
var tps = sectionTitleArray.objectAtIndex(section) as! String
var count1 = (sectionContentDict.valueForKey(tps)) as! NSArray
return count1.count
}
return 0;
}
func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return "ABC"
}
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 50
}
func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if(arrayForBool .objectAtIndex(indexPath.section).boolValue == true){
return 50
}
return 2;
}
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let cell = self.tableView.dequeueReusableCellWithIdentifier("CategoryNameTableCell") as! CategoryNameTableCell
cell.downArrow.hidden = false
cell.backgroundColor = UIColor.blackColor()
cell.tag = section
cell.CategoryLabel.text = sectionTitleArray.objectAtIndex(section) as? String
let cellTapped = UITapGestureRecognizer (target: self, action:"sectionHeaderTapped:")
cell .addGestureRecognizer(cellTapped)
return cell
}
func sectionHeaderTapped(recognizer: UITapGestureRecognizer) {
println("Tapping working")
println(recognizer.view?.tag)
var indexPath : NSIndexPath = NSIndexPath(forRow: 0, inSection:(recognizer.view?.tag as Int!)!)
if (indexPath.row == 0) {
var collapsed = arrayForBool .objectAtIndex(indexPath.section).boolValue
collapsed = !collapsed;
arrayForBool .replaceObjectAtIndex(indexPath.section, withObject: collapsed)
var range = NSMakeRange(indexPath.section, 1)
var sectionToReload = NSIndexSet(indexesInRange: range)
self.tableView .reloadSections(sectionToReload, withRowAnimation:UITableViewRowAnimation.Fade)
tableView.reloadData()
}
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let cell = self.tableView.dequeueReusableCellWithIdentifier("CategoryNameTableCell") as! CategoryNameTableCell
var manyCells : Bool = arrayForBool .objectAtIndex(indexPath.section).boolValue
if (!manyCells) {
} else {
var content = sectionContentDict .valueForKey(sectionTitleArray.objectAtIndex(indexPath.section) as! String) as! NSArray
cell.CategoryLabel.text = content .objectAtIndex(indexPath.row) as? String
cell.backgroundColor = UIColor( red: 49/255, green: 46/255, blue:47/255, alpha: 1.0 )
}
return cell
}
func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
println(indexPath.row)
}

I don't know why you need sections to do it what you want, you can achieve with normal cells, no need to complicate at all. Just differentiating the parent cells of the child cells is all you need.
I have a repository in Github that achieve what you want, without using sections neither UITapGestureRecognizer. As soon as possible I'll try to update the project to better performance and more levels of depth in the dropdown.
You can reach it AccordionMenu
, and feel free to post anything you need as issue.
I hope this help you.

Related

tableView not showing the data in an array swift

I have a tableView connected to the array. The array isn't empty but the tableView shows nothing other than lines. Can you help me, please?
var invoicesDictionary = [String:[String]]()
var invoicesSectionTitles = [String]()
var invoices: [String] = ["JV1", "R1", "JV2"]
#IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
for invoice in invoices {
let invoiceKey = String(invoice.prefix(1))
if var invoiceValues = self.invoicesDictionary[invoiceKey] {
invoiceValues.append(invoice)
self.invoicesDictionary[invoiceKey] = invoiceValues
} else {
self.invoicesDictionary[invoiceKey] = [invoice]
}
}
invoicesSectionTitles = [String](invoicesDictionary.keys)
invoicesSectionTitles = invoicesSectionTitles.sorted(by: { $0 < $1 })
tableView.reloadData()
}
func numberOfSections(in tableView: UITableView) -> Int {
return invoicesSectionTitles.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
let invoiceKey = invoicesSectionTitles[section]
if let invoiceValues = invoicesDictionary[invoiceKey] {
return invoiceValues.count
}
return 0
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
let invoiceKey = invoicesSectionTitles[indexPath.section]
if let invoiceValues = invoicesDictionary[invoiceKey] {
cell.textLabel?.text = invoiceValues[indexPath.row]
}
return cell
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return invoicesSectionTitles[section]
}
func sectionIndexTitles(for tableView: UITableView) -> [String]? {
return invoicesSectionTitles
}
I printed out the array which is without a doubt not empty. I tried this code on an another project and it just worked.
You have to put this in viewDidLoad :
tableView.delegate = self
tableView.dataSource = self
You have to tell the View controller that it's the delegate or assigned VC for the table View functionality by passing the following lines inside viewDidLoad()
tableView.delegate = self
tableView.dataSource = self

UITableView is working fine in simulator but not in my physical device

I am currently building an Application which shows all the faculties that are available in my college. I have the data in a .plist file which I have read and populated in the UITableView. I am currently trying to show some details such as prefix and Name in the cell which when clicked on Expands to show more details about the faculty.
My TableViewController Code is shown below:
struct cellData {
var opened = Bool()
var Name = String()
var Prefix = String()
var sectionData = [String]()
}
class TableViewController: UITableViewController {
//MARK: - Initialize variables
var dataManager = DataManager()
private var header = [String]()
private var facultyDetails = [[String: String]]()
var tableViewData = [cellData]()
#IBOutlet var facultyTableView: UITableView!
//MARK: - view did load
override func viewDidLoad() {
super.viewDidLoad()
for data in dataManager.allSheet1s() {
let dataInCell = cellData(opened: false, Name: data.item2!,
Prefix: data.item1!, sectionData [data.item0!,
data.item2!,
data.item1!,
data.item3!,
data.item4!,
data.item5!,
data.item6!,
data.item7!,
data.item8!,
data.item9!,
data.item10!
])
tableViewData.append(dataInCell)
facultyTableView.register(UINib(nibName: "CustomCell", bundle: nil), forCellReuseIdentifier: "CustomCell")
}
}
// MARK: - Table view delegate
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return tableViewData.count
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomCell") as! CustomCell
if indexPath.row == 0 {
cell.EmpID.text = tableViewData[indexPath.section].sectionData[0]
cell.Name.text = tableViewData[indexPath.section].sectionData[1]
cell.Prefix.text = tableViewData[indexPath.section].sectionData[2]
cell.SchoolName.text = tableViewData[indexPath.section].sectionData[3]
cell.BuildingName.text = tableViewData[indexPath.section].sectionData[4]
cell.FloorNo.text = tableViewData[indexPath.section].sectionData[5]
cell.CabinLocation.text = tableViewData[indexPath.section].sectionData[6]
cell.RoomNo.text = tableViewData[indexPath.section].sectionData[7]
cell.CabinNo.text = tableViewData[indexPath.section].sectionData[8]
cell.IntercomNumber.text = tableViewData[indexPath.section].sectionData[9]
cell.Email.text = tableViewData[indexPath.section].sectionData[10]
return cell
}
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if tableViewData[indexPath.section].opened == true {
tableViewData[indexPath.section].opened = false
let sections = IndexSet.init(integer: indexPath.section)
tableView.reloadSections(sections, with: .right)
}
else {
tableViewData[indexPath.section].opened = true
let sections = IndexSet.init(integer: indexPath.section)
tableView.reloadSections(sections, with: .left)
}
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if tableViewData[indexPath.section].opened == true {
return 400
}
else {
return 70
}
}
}
Simulator
Physical Device
Right now you can see in the simulator that it works perfectly fine. But when I load it up in the physical device the height of each cell in the rows are clipping through the other cells below it.
Modify your cell for row code by adding cell.clipsToBounds = true
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomCell") as! CustomCell
cell.clipsToBounds = true
if indexPath.row == 0 {
cell.EmpID.text = tableViewData[indexPath.section].sectionData[0]
cell.Name.text = tableViewData[indexPath.section].sectionData[1]
cell.Prefix.text = tableViewData[indexPath.section].sectionData[2]
cell.SchoolName.text = tableViewData[indexPath.section].sectionData[3]
cell.BuildingName.text = tableViewData[indexPath.section].sectionData[4]
cell.FloorNo.text = tableViewData[indexPath.section].sectionData[5]
cell.CabinLocation.text = tableViewData[indexPath.section].sectionData[6]
cell.RoomNo.text = tableViewData[indexPath.section].sectionData[7]
cell.CabinNo.text = tableViewData[indexPath.section].sectionData[8]
cell.IntercomNumber.text = tableViewData[indexPath.section].sectionData[9]
cell.Email.text = tableViewData[indexPath.section].sectionData[10]
return cell
}
return cell
}
And override a method
override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return 70
}

UITableView performance problem with HeaderCell

I have a performance issue when HeaderCell becomes visible, it takes up to 40% of CPU on iPhone X and I see lags. This UITableView displays static data (TV guide). I see lags every time when I scroll up and down, "tableView.dequeueReusableCell()" doesn't help. If I use my ExpandableHeaderView() to create HeaderCell for supporting tapping and expanding section, I have the same issue. If expand section and scrolls inside elements, I do not see lags. Performance problem occurs only when HeaderCell appears on the screen. When user opens View Controller, he sees 3 programs for each channel (current and next two), if he taps on section name, he sees all programs for section (channel). HeaderCell contains only Label. I display the same data in the same way on my Android app and it works without any problems on simple Android device.
func numberOfSections(in tableView: UITableView) -> Int {
return Channels.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return Channels[section].Programs.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifier)! as! TVGuideTableViewCell
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "HH:mm"
let text = Channels[indexPath.section].Programs[indexPath.row].Name
let dateString = dateFormatter.string(from:Channels[indexPath.section].Programs[indexPath.row].StartDate!)
cell.label.text = text
cell.timeLabel.text = dateString
if (Channels[indexPath.section].Programs[indexPath.row].EndDate! < currentDate) {
cell.label.textColor = UIColor.gray
} else {
cell.label.textColor = UIColor.white
}
if (Channels[indexPath.section].Programs[indexPath.row].StartDate! < currentDate) {
cell.bell.isHidden = true
} else {
cell.bell.isHidden = false
}
if (Channels[indexPath.section].Programs[indexPath.row].EndDate! < currentDate) {
Channels[indexPath.section].Programs[indexPath.row].expandedRow = false
} else {
if Channels[indexPath.section].expandedCount < 3 {
Channels[indexPath.section].expandedCount += 1
Channels[indexPath.section].Programs[indexPath.row].expandedRow = true
}
}
return cell
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerCell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifierHeader) as! CustomHeaderTableViewCell
headerCell.headerLabel.text = Channels[section].Name
return headerCell
// let header = ExpandableHeaderView()
// header.customInit(title: Channels[section].Name, section: section, delegate: self as ExpandableHeaderViewDelegate)
// return header
}
func toggleSection(header: ExpandableHeaderView, section: Int) {
Channels[section].expanded = !Channels[section].expanded
Channels[section].expandedCount = 0
tableView.beginUpdates()
for i in 0 ..< Channels[section].Programs.count {
tableView.reloadRows(at: [IndexPath(row: i, section: section)], with: .automatic)
}
tableView.endUpdates()
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 38
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 2
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if(Channels[indexPath.section].expanded) {
return 38
} else {
if (Channels[indexPath.section].Programs[indexPath.row].EndDate! < currentDate) {
return 0
} else {
if Channels[indexPath.section].Programs[indexPath.row].expandedRow {
return 38.0
} else {
return 0.0
}
}
}
}
class CustomHeaderTableViewCell: UITableViewCell {
#IBOutlet weak var headerLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
From your code, what I can see that the problem is not HeaderCell, the problem is DateFormatter object. Because everytime you scroll and cell appears a new object is created and just imagine that if there are 10 - 15 cells at a time then 10 - 15 reused / created and as you scroll or reloadData it again create a new object.
So, my advise is to create the DateFormatter object outside cellforRow and then just use it to get to get a dateString by calling it.
This is just one assumption, try this and project still appears do let me know!

I get the error "index 6 beyond bounds [0 .. 5]' " when implementing search in my app

Here's my code. While following multiple tutorials on how to implement search in Swift I've had no luck.
import UIKit
class DataTableExercisesTableViewController: UITableViewController, UISearchBarDelegate, UISearchResultsUpdating {
var exercises = ["Abs", "Arms", "Back", "Chest", "Legs", "Shoulders", "Triceps"]
var searchActive : Bool = false
#IBOutlet weak var searchBar: UISearchBar!
var filteredTableData = [String]()
var resultSearchController = UISearchController()
override func viewDidLoad() {
super.viewDidLoad()
self.resultSearchController = ({
let controller = UISearchController(searchResultsController: nil)
controller.searchResultsUpdater = self
controller.dimsBackgroundDuringPresentation = false
controller.searchBar.sizeToFit()
self.tableView.tableHeaderView = controller.searchBar
return controller
})()
// Reload the table
self.tableView.reloadData()
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return exercises.count;
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell")! as UITableViewCell;
if (self.resultSearchController.active) {
cell.textLabel?.text = filteredTableData[indexPath.row]
return cell
}
else {
cell.textLabel?.text = exercises[indexPath.row]
return cell
}
}
func updateSearchResultsForSearchController(searchController: UISearchController)
{
filteredTableData.removeAll(keepCapacity: false)
let searchPredicate = NSPredicate(format: "SELF CONTAINS[c] %#", searchController.searchBar.text!)
let array = (exercises as NSArray).filteredArrayUsingPredicate(searchPredicate)
filteredTableData = array as! [String]
self.tableView.reloadData()
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
self.tableView.reloadData()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
I've been having trouble implementing search from different tutorials and just doesn't seem to be working out too well. Any insight is much appreciated.
Your numberOfRowsInSection is always returning exercises.count. But when you are filtering, you are not using exercises, but a smaller array, filteredTableData. So, just as in cellForRowAtIndexPath, you need to change your answer if you are filtering.
The best solution is before access the array value just the check the total count should less the the index you want fetch from the array or use below way to iterate the array
EX :
let arrayOfInts: [Int] = [1, 2, 3];
for i in arrayOfInts {
print(i);
}
In your case you could change the code :
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
var rowCount = 0
if(self.resultSearchController.active){
rowCount = filteredTableData.count
}
else{
rowCount = exercises.count
}
return rowCount;
}

Making Simple Accordion TableView in swift?

Is there any way that I can make simple Accordion View in swift like the one at Calendar Event Create? I don't want to use other third party library as well as other code.
I found many answer at github and over google. But,still don't meet my requirement.
Actually I want to add two table view.
The first one is section which show City such as (New York,Los Angles,Las Vegas,etc)
When I tapped one of the city,it will show store address in tableview which mean there are many stores.
All the store and data will got from json.
The accordion view that i want to do is as simple as the one at Calendar App on iOS. But,the data that I gonna insert into two tableView (Section Header & Inner Records inside each section) which is dynamic.
Any Help? Please Guide me,Help me out.
UPDATE : Please take a look
The answer provided by #TechBee works fine using sections for those interested in not using sections and use cells.
The implementation of an Accordion Menu in Swift can be achieved using UITableView in a very simple way, just having two cells one for the parent cells and another for the childs cells and in every moment keep the track for the cells expanded or collapsed because it can change the indexPath.row every time a new cell is expanded or collapsed.
Using the functions insertRowsAtIndexPaths(_:withRowAnimation:) and deleteRowsAtIndexPaths(_:withRowAnimation:) always inside a block of call to tableView.beginUpdates() and tableView.endUpdates() and updating the total of items in the data source or simulating it changes we can achieve the insertion of deletion of new cells in the UITableView in a very easy way with animation included.
I've implemented myself a repository in Github with all the explained above AccordionMenu using Swift and UITableView in a easy and understandable way. It allows several cells expanded or only one at time.
Try this:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
arrayForBool = ["0","0","0"]
sectionTitleArray = ["Pool A","Pool B","Pool C"]
var tmp1 : NSArray = ["New Zealand","Australia","Bangladesh","Sri Lanka"]
var string1 = sectionTitleArray .objectAtIndex(0) as? String
[sectionContentDict .setValue(tmp1, forKey:string1! )]
var tmp2 : NSArray = ["India","South Africa","UAE","Pakistan"]
string1 = sectionTitleArray .objectAtIndex(1) as? String
[sectionContentDict .setValue(tmp2, forKey:string1! )]
self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return sectionTitleArray.count
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
if(arrayForBool .objectAtIndex(section).boolValue == true)
{
var tps = sectionTitleArray.objectAtIndex(section) as! String
var count1 = (sectionContentDict.valueForKey(tps)) as! NSArray
return count1.count
}
return 0;
}
func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return "ABC"
}
func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 50
}
func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 1
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if(arrayForBool .objectAtIndex(indexPath.section).boolValue == true){
return 100
}
return 2;
}
func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerView = UIView(frame: CGRectMake(0, 0, tableView.frame.size.width, 40))
headerView.backgroundColor = UIColor.grayColor()
headerView.tag = section
let headerString = UILabel(frame: CGRect(x: 10, y: 10, width: tableView.frame.size.width-10, height: 30)) as UILabel
headerString.text = sectionTitleArray.objectAtIndex(section) as? String
headerView .addSubview(headerString)
let headerTapped = UITapGestureRecognizer (target: self, action:"sectionHeaderTapped:")
headerView .addGestureRecognizer(headerTapped)
return headerView
}
func sectionHeaderTapped(recognizer: UITapGestureRecognizer) {
println("Tapping working")
println(recognizer.view?.tag)
var indexPath : NSIndexPath = NSIndexPath(forRow: 0, inSection:(recognizer.view?.tag as Int!)!)
if (indexPath.row == 0) {
var collapsed = arrayForBool .objectAtIndex(indexPath.section).boolValue
collapsed = !collapsed;
arrayForBool .replaceObjectAtIndex(indexPath.section, withObject: collapsed)
//reload specific section animated
var range = NSMakeRange(indexPath.section, 1)
var sectionToReload = NSIndexSet(indexesInRange: range)
self.tableView .reloadSections(sectionToReload, withRowAnimation:UITableViewRowAnimation.Fade)
}
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let CellIdentifier = "Cell"
var cell :UITableViewCell
cell = self.tableView.dequeueReusableCellWithIdentifier(CellIdentifier) as! UITableViewCell
var manyCells : Bool = arrayForBool .objectAtIndex(indexPath.section).boolValue
if (!manyCells) {
// cell.textLabel.text = #"click to enlarge";
}
else{
var content = sectionContentDict .valueForKey(sectionTitleArray.objectAtIndex(indexPath.section) as! String) as! NSArray
cell.textLabel?.text = content .objectAtIndex(indexPath.row) as? String
cell.backgroundColor = UIColor .greenColor()
}
return cell
}