Is there a better way to write this? This is a class that displays a preferences menu. We do this when the user first installs the app during a walk-through where we only show them some of the settings with additional guidance on how to set them. We also show the entire preferences menu if the user selects our preferences button.
/**
Manages the height of the table's cells, hiding them if necessary.
parameter: The table we'll edit
parameter: The height in dpi of the row at a given row
*/
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
switch walkthroughStep {
// step 1 of the walkthrough
case 1:
switch indexPath.row {
case 0: return 0.1
case 3:
if ((promptLabel.intrinsicContentSize().height * promptLabel.font.pointSize) > 350){
//print ("the result of this is: ---------- \(promptLabel.intrinsicContentSize().height * promptLabel.font.pointSize)")
return 80
}
else { return 50.0 }
case 4: return 9.0
case 5: return 0.1
case 6: return 0.1
case 7: return 0.1
case 8: return 0.1
case 9: return 0.1
case 10: return 0.1
case 11: return 0.1
default: break
}
// step 2 of the walkthrough
case 2: switch indexPath.row {
// hide all cells of teh default methos table
case 0: return 0.1
case 1: return 0.1
case 2: return 0.1
case 3: return 0.1
case 4: return 0.1
case 5:
if enableNotifications.on {
return selectedCellHeight
}
return unselectedCellHeight
case 6: return 9.0
// hide propmt me to modify number cell
case 7: return 0.1
case 8: return 0.1
case 9: return 0.1
case 10: return 0.1
case 11: return 0.1
default: break
}
// normal state
default:
switch indexPath.row {
// hide all cells of teh default methos table
case 0: return 50.0
case 1: return 50.0
case 2: return 50.0
case 3:
if ((promptLabel.intrinsicContentSize().height * promptLabel.font.pointSize) > 350){
//print ("the result of this is: ---------- \(promptLabel.intrinsicContentSize().height * promptLabel.font.pointSize)")
return 80
}
else { return 50.0 }
case 4: return 9.0
case 5:
if enableNotifications.on {
return selectedCellHeight
}
return unselectedCellHeight
case 6: return 9.0
// hide propmt me to modify number cell
case 7:
if ((modifyNumbersLabel.intrinsicContentSize().height * modifyNumbersLabel.font.pointSize) > 310){
//print ("the result of this is: ---------- \(modifyNumbersLabel.intrinsicContentSize().height * modifyNumbersLabel.font.pointSize)")
return 90
}
else { return 50.0 }
case 8: return 9.0
case 9: return 50.0
case 10: return 50.0
case 11: return 50.0
default: break
}
}
return 50.0
}