Don_Mag icon

Untitled

Don_Mag | PRO | 08/25/23 07:17:15 PM UTC | 0 ⭐ | 8676 👁️ | Never ⏰ | []
Swift |

2.86 KB

|

None

|

0 👍

/

0 👎

class OldRecordsTableViewCell: UITableViewCell {
    static let identifier: String = "c"
}
 
class RecordingViewController: UIViewController {
    
    private let tableView: UITableView = {
        let tableView = UITableView()
        tableView.translatesAutoresizingMaskIntoConstraints = false
        tableView.register(OldRecordsTableViewCell.self, forCellReuseIdentifier: OldRecordsTableViewCell.identifier)
        tableView.separatorStyle = .none
        tableView.backgroundColor = .clear
        tableView.isScrollEnabled = true
        return tableView
    }()
    
    let allRecordsLabel = UILabel()
    let contentView1 = UIView()
    
    override func viewDidLoad() {
        super.viewDidLoad()
 
        allRecordsLabel.translatesAutoresizingMaskIntoConstraints = false
        contentView1.translatesAutoresizingMaskIntoConstraints = false
        
        view.addSubview(contentView1)
        contentView1.addSubview(allRecordsLabel)
        contentView1.addSubview(tableView)
        
        NSLayoutConstraint.activate([
            contentView1.topAnchor.constraint(equalTo: view.topAnchor),
            contentView1.leadingAnchor.constraint(equalTo: view.leadingAnchor),
            contentView1.trailingAnchor.constraint(equalTo: view.trailingAnchor),
            contentView1.bottomAnchor.constraint(equalTo: view.bottomAnchor),
            
            allRecordsLabel.topAnchor.constraint(equalTo: contentView1.topAnchor, constant: 80.0),
            allRecordsLabel.leadingAnchor.constraint(equalTo: contentView1.leadingAnchor),
            allRecordsLabel.trailingAnchor.constraint(equalTo: contentView1.trailingAnchor),
 
            tableView.topAnchor.constraint(equalTo: allRecordsLabel.bottomAnchor, constant: 26.5),
            tableView.bottomAnchor.constraint(equalTo: contentView1.bottomAnchor, constant: -15),
            tableView.leadingAnchor.constraint(equalTo: contentView1.leadingAnchor, constant: 43),
            tableView.trailingAnchor.constraint(equalTo: contentView1.trailingAnchor, constant: -43)
        ])
 
        allRecordsLabel.text = "All Records"
        
        view.backgroundColor = .systemYellow
        contentView1.backgroundColor = .systemBlue
        allRecordsLabel.backgroundColor = .green
        
        tableView.dataSource = self
        tableView.delegate = self
        
    }
 
    
}
 
extension RecordingViewController: UITableViewDataSource, UITableViewDelegate {
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 20
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: OldRecordsTableViewCell.identifier, for: indexPath) as! OldRecordsTableViewCell
        cell.textLabel?.text = "Text \(indexPath.row)"
        return cell
    }
    
    func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
        
        print("Content Size: \(tableView.contentSize)")
        print("Bounds Size: \(tableView.bounds.size)")
        
        return true
    }
}
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎