Advertisement
Guest User

Untitled

a guest
Jan 19th, 2015
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. import UIKit
  2.  
  3. class SecondViewController: UIViewController, UIAlertViewDelegate{
  4.  
  5. @IBOutlet weak var tableView: UITableView!
  6. @IBOutlet weak var toolbar: UIToolbar!
  7. @IBOutlet weak var addButton: UIBarButtonItem!
  8. @IBOutlet weak var editButton: UIBarButtonItem!
  9. @IBOutlet weak var tblTasks: UITableView!
  10. @IBOutlet weak var createButton: UIBarButtonItem!
  11.  
  12. var users: [String] = []
  13.  
  14.  
  15. @IBAction func addButtonPressed(sender: AnyObject) {
  16.  
  17. var alert = UIAlertView(title: "Enter the title", message: "This will be the name of your project", delegate: self, cancelButtonTitle: "Cancel")
  18.  
  19. alert.alertViewStyle = UIAlertViewStyle.PlainTextInput
  20. alert.addButtonWithTitle("Continue")
  21. alert.show()
  22. }
  23.  
  24. @IBAction func editButtonPressed(sender: AnyObject) {
  25.  
  26. }
  27.  
  28. @IBAction func create(sender: AnyObject) {
  29.  
  30. }
  31.  
  32.  
  33. override func viewDidLoad() {
  34. super.viewDidLoad()
  35.  
  36. // Do any additional setup after loading the view.
  37.  
  38.  
  39. }
  40.  
  41. override func didReceiveMemoryWarning() {
  42. super.didReceiveMemoryWarning()
  43. // Dispose of any resources that can be recreated.
  44. }
  45.  
  46. func numberOfSectionsInTableView(tableView: UITableView) -> Int {
  47. return 1
  48. }
  49.  
  50. func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  51. return users.count
  52. }
  53.  
  54. func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
  55. let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
  56.  
  57. // Set the label text as the users name
  58. cell.textLabel!.text = users[indexPath.row]
  59.  
  60. return cell
  61. }
  62.  
  63. func alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int) {
  64. if buttonIndex == 1 {
  65. users.append(alertView.textFieldAtIndex(0)!.text)
  66. tableView.reloadData()
  67. }
  68. }
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement