2015-10-22 27 views

回答

1

我不明白你用按鈕做什麼。我和我的團隊通常使用表單元格,就像菜單項一樣。像這樣的例子

enter image description here

enter image description here

  • 我定義了一個菜單項數組

    var menuItems = ["Sign in", "My abc", "My def"]

  • 與代碼功能標誌,刪除 「登錄」,並添加「我的帳戶」。在我簡單的例子,我用didSelectRowAtIndex並勾選「登錄」菜單

    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 
    
    // sign in item 
        if indexPath.row == 0 && menuItems[0] == "Sign in" { 
    
         let alert = UIAlertController(title: "Signing in", message: "Press OK to sign in", preferredStyle: .Alert) 
    
         alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil)) 
    
         alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { (UIAlertAction) -> Void in 
    
          self.menuItems.removeAtIndex(0) 
          self.menuItems.insert("My Account", atIndex: 0) 
    
          tableView.reloadData() 
         })) 
    
         presentViewController(alert, animated: true, completion: nil) 
    
         } 
        } 
    

希望這有助於。

+0

謝謝你解決我的問題 –

相關問題