Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // SecondController.swift
- // test3
- //
- // Created by Padow Usmar on 2014/10/19.
- // Copyright (c) 2014年 Padow Usmar. All rights reserved.
- //
- import UIKit
- var data = NSMutableArray()
- class SecondController: UIViewController,UITableViewDelegate, UITableViewDataSource{
- @IBOutlet var t1 : UITextField!;
- @IBOutlet var tv1 : UITableView!;
- @IBAction func BtnTouchSend(mybutton: UIButton) {
- var Line : String;
- Line=t1.text
- data.addObject(Line)
- tv1.reloadData()
- //scrolls to the bottom
- //tv1.scrollToNearestSelectedRowAtScrollPosition(UITableViewScrollPosition.Bottom, animated:true)
- //tv1.indexPathForCell(cell: tv1.cell)
- //tv1.scrollToRowAtIndexPath(NSIndexPath.,atScrollPosition: UITableViewScrollPosition.Bottom, animated:true)
- }
- //UITableDatasource
- func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return data.count
- }
- // Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
- // Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)
- func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
- var cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "empty")
- cell.textLabel?.text=data[indexPath.row] as? String
- return cell
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement