Programmatically UITableView using swift

前端 未结 4 1609
广开言路
广开言路 2020-12-30 00:59

I\'m trying to create a simple tableView programmatically using swift, so I wrote this code on \"AppDelegate.swift\" :

    func application(application: UIA         


        
4条回答
  •  天涯浪人
    2020-12-30 01:24

    It is as simple as writing a function

        func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
    {
        let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "MyTestCell")
    
        cell.text = self.Myarray[indexPath.row]
        cell.textLabel.textColor = UIColor.greenColor()
    
        cell.detailTextLabel.text = "DummyData #\(indexPath.row)"
        cell.detailTextLabel.textColor = UIColor.redColor()
        cell.imageView.image = UIImage(named:"123.png")
        return cell
    }
    

提交回复
热议问题