         expansionList![sender.tag] = !expansionList![sender.tag]
         tableView.reloadSections(NSIndexSet(index: sender.tag), withRowAnimation: UITableViewRowAnimation.Automatic)
     }
+    
+    func expandTable() {
+        expand = !expand;
+    }
+    
     @IBAction func addCategory(sender: UIButton) {
         let ac = UIAlertController(title: "新建分类名", message: nil, preferredStyle: UIAlertControllerStyle.Alert)
         ac.addTextFieldWithConfigurationHandler { (textField: UITextField) -> Void in

class PMItemListController: UITableViewController {
    var catList : NSMutableArray?
    var expansionList : Array<Bool>?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        

    
    override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        let btn = UIButton(frame:CGRectMake(0,0,0,44))
        btn.setTitleColor(UIColor.grayColor(), forState: UIControlState.Normal)
        btn.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Left
        btn.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0)
        //        btn.titleLabel?.textAlignment = NSTextAlignment.Left
        btn.titleLabel?.font = UIFont.systemFontOfSize(12)
        if let cat = catList?[section] as? Category {
            btn .setTitle(cat.name, forState: UIControlState.Normal)
