Advertisement
amigojapan

testing swift iOS chat

Oct 19th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. //
  2. // SecondController.swift
  3. // test3
  4. //
  5. // Created by Padow Usmar on 2014/10/19.
  6. // Copyright (c) 2014年 Padow Usmar. All rights reserved.
  7. //
  8.  
  9.  
  10.  
  11. import UIKit
  12.  
  13. var data = NSMutableArray()
  14.  
  15.  
  16. class SecondController: UIViewController,UITableViewDelegate, UITableViewDataSource{
  17. @IBOutlet var t1 : UITextField!;
  18.  
  19. @IBOutlet var tv1 : UITableView!;
  20.  
  21.  
  22.  
  23. @IBAction func BtnTouchSend(mybutton: UIButton) {
  24. var Line : String;
  25. Line=t1.text
  26. data.addObject(Line)
  27. tv1.reloadData()
  28. //scrolls to the bottom
  29. //tv1.scrollToNearestSelectedRowAtScrollPosition(UITableViewScrollPosition.Bottom, animated:true)
  30. //tv1.indexPathForCell(cell: tv1.cell)
  31.  
  32. //tv1.scrollToRowAtIndexPath(NSIndexPath.,atScrollPosition: UITableViewScrollPosition.Bottom, animated:true)
  33. }
  34.  
  35. //UITableDatasource
  36.  
  37. func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  38. return data.count
  39.  
  40. }
  41.  
  42. // Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
  43. // Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)
  44.  
  45. func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
  46. var cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "empty")
  47. cell.textLabel?.text=data[indexPath.row] as? String
  48. return cell
  49. }
  50.  
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement