`
ipython
  • 浏览: 288893 次
  • 性别: Icon_minigender_1
  • 来自: 佛山
社区版块
存档分类
最新评论

swift tableview xcode 6.01

 
阅读更多

Hello Tableview in Swift  xcode 6.01

 

1. create a single view application project
2. [optional], uncheck the auto layout

3. drag a tableview into view controller , link it as datasource

4. add some code below to ViewController.swift

// ------------

    let tableData = ["Apple", "Google", "IBM", "Facebook"]

    

    func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {

        return countElements(tableData)

    }

    

    

    func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {

        let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "MyTestCell")

        

        cell.detailTextLabel!.text = tableData[indexPath.row]

        return cell

 

    }

// ------------
5. run  (command + R)

  • 大小: 26.9 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics