0

In myscenario, I have created static cell with multiple sections. Now, I need to load dynamic cell bottom of the last static cell. Here, I am using UITableviewController with cell type Static. I tried below code but it is not working. I can able to see only static cells but dynamic cell not loading.

enter image description here

TableviewController Delegates

var Titles = ["Food","Travel","Lifestyle","Card","MyReserve","Game","Songs","Movies","Entertainment","Business","Education","Finance","Drink","Sports","Social","Shopping"]

override func numberOfSections(in tableView: UITableView) -> Int {
        return 4
    }

    override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
        if(section == 0) {
            return " "
        } else if(section == 1) {
            return " "
        } else if(section == 2) {
            return " "
        } else {
            return " "
        }
    }

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

        if (section == 0) {
            return 2
        } else if(section == 1) {
            return 1
        } else if(section == 2) {
            return 3
        }
        return self.Titles.count
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath as IndexPath) as UITableViewCell

        if indexPath.section != 0 && indexPath.section != 1 && indexPath.section != 2 {
            let celltitle. = tableView.dequeueReusableCell(withIdentifier: "dynamiccell", for: indexPath as IndexPath) as UITableViewCell
            celltitle.textLabel?.text = self.Titles[indexPath.row]
            return celltitle.
        }
        return cell
    }

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        if indexPath.section == 0 && indexPath.row == 0 {
        } else if indexPath.section == 0 && indexPath.row == 1 {
        } else if indexPath.section == 1 && indexPath.row == 0 {
        } else if indexPath.section == 2 && indexPath.row == 0 {
        } else if indexPath.section == 2 && indexPath.row == 1 {
        } else if indexPath.section == 2 && indexPath.row == 2 {
        } else {
        }
    }
iosdev
  • 125
  • 2
  • 17

0 Answers0