কম্পিউটার টিউটোরিয়াল

সুইফটে টেবিল ভিউর শেষে সাবমিট বাটন (Submit Button) যোগ করার পদ্ধতি


TableView Footer View ব্যবহার করে টেবিলের নিচে বাটন যোগ করুন।

func initTableView() {
    let tableView = UITableView()
    tableView.frame = self.view.frame
    tableView.dataSource = self
    tableView.delegate = self
    tableView.backgroundColor = .lightGray
    tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
    self.view.addSubview(tableView)
}

func numberOfSections(in tableView: UITableView) -> Int { return 1 }
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 2 }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell")!
    cell.layer.backgroundColor = UIColor.systemBlue.cgColor
    cell.textLabel?.text = "cell at \(indexPath.row)"
    return cell
}

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 60 }
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return 100 }

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
    let footerView = UIView()
    footerView.backgroundColor = .systemYellow
    footerView.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: 100)
    let button = UIButton()
    button.frame = CGRect(x: 20, y: 10, width: 300, height: 50)
    button.setTitle("CustomButton", for: .normal)
    button.setTitleColor(.black, for: .normal)
    button.backgroundColor = .systemGreen
    footerView.addSubview(button)
    return footerView
}

ফলাফল —

সুইফটে টেবিল ভিউর শেষে সাবমিট বাটন (Submit Button) যোগ করার পদ্ধতি


  1. Matplotlib-এ X-অক্ষের নিচে ফুটনোট যোগ করার পদ্ধতি

  2. টকিন্টার পাইথনে বাটন চাপলে এন্ট্রি উইজেট ক্লিয়ার করা

  3. Dropbox ব্যবহার করে Apple Books অ্যাপে PDF যোগ করার পদ্ধতি

  4. সুইফ্টের সাথে iOS CRUD অ্যাপে রিয়েল্ম ডেটাবেস ইন্টিগ্রেশন: ধাপে ধাপে গাইড