Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- class MyViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
- @IBOutlet weak var tableView: UITableView!
- override func viewDidLoad() {
- super.viewDidLoad()
- }
- func numberOfSections(in tableView: UITableView) -> Int {
- return 2
- }
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- if section == 0 {
- return 3
- } else {
- return 2
- }
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- if indexPath.section == 0 {
- let cell = tableView.dequeueReusableCell(withIdentifier: "MyTableViewCell", for: indexPath)
- cell.textLabel?.text = "Prototype"
- return cell
- } else {
- let cell = tableView.dequeueReusableCell(withIdentifier: "MySecondTableViewCell", for: indexPath)
- cell.textLabel?.text = "Other"
- return cell
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement