• swift开发笔记06


    // 自定义cell

    class Cell: UITableViewCell {

        

        @IBOutlet weak var fenLei: UILabel!

        @IBOutlet weak var tangGuoMing: UILabel!

        

        

        var mode: Candy!

        {

            didSet {

                updateUI()

            }

        }

        

        fileprivate func updateUI()

        {

            fenLei.text = mode.name

            tangGuoMing.text =  mode.category

        }

        

    }

    // prepare

        override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

            let vc = segue.destination as! UINavigationController

            if  let index = myTableView.indexPathForSelectedRow {

                let candy: Candy

                if searchController.isActive {

                    candy = filterCandies[(index.row)]

                } else {

                    candy = arrMode[(index.row)]

                }

                let detail = vc.topViewController as! ViewController

                detail.mode = candy

            }

            

            

        }

     

    // searchController初始化

        func setSearchController() -> Void {

            searchController.dimsBackgroundDuringPresentation = false

            definesPresentationContext = true

            myTableView.tableHeaderView = searchController.searchBar

            searchController.searchBar.scopeButtonTitles = ["All", "Chocolate", "Hard", "Other"]

            searchController.searchBar.delegate = self

            searchController.searchResultsUpdater = self

        }

     

        func updateSearchResults(for searchController: UISearchController) {

            let searchBar = searchController.searchBar

            let scope = searchBar.scopeButtonTitles![searchBar.selectedScopeButtonIndex]

            filterContentForSearchText(text: searchBar.text!, scope: scope)

        }

        

        func searchBar(_ searchBar: UISearchBar, selectedScopeButtonIndexDidChange selectedScope: Int) {

            filterContentForSearchText(text: searchBar.text!, scope: searchBar.scopeButtonTitles![selectedScope])

        }

  • 相关阅读:
    64位内核开发第十二讲,进程监视,ring3跟ring0事件同步.
    64位内核开发第十讲,IRQL中断级别了解
    64位内核开发第九讲,注册表编程.
    64位内核开发第8讲,文件操作.以及删除文件.
    64位内核第七讲.内核中字符串编程注意事项
    【Unity】7.5 移动设备输入
    【Unity】7.4 游戏外设输入
    【Unity】7.3 键盘输入
    【Unity】7.2 鼠标输入
    【Unity】7.1 Input类的方法和变量
  • 原文地址:https://www.cnblogs.com/dengchaojie/p/7346645.html
Copyright © 2020-2023  润新知