UITableView-এ সেল ইনসার্ট করতে কাস্টম সেল তৈরি করে cellForRowAt মেথডে ডিকিউ (dequeue) করুন।
- ViewController-এ TableView আউटलেট যোগ করুন।
- Storyboard-এ প্রোটোটাইপ সেল তৈরি করুন, ক্লাস:
CustomCell, Identifier:"CustomCell"। - সেলে একটি লেবেল যোগ করুন।
func numberOfSections(in tableView: UITableView) -> Int { return 1 }
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 5 }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomCell") as! CustomCell
return cell
}
রান করলে ৫টি সেলের টেবিল দেখাবে।
