zoukankan      html  css  js  c++  java
  • 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])

        }

  • 相关阅读:
    BZOJ 1834 Luogu P2604 [ZJOI2010]网络扩容 (最小费用最大流)
    BZOJ 1565 Luogu P2805 [NOI2009]植物大战僵尸 (Tarjan判环、最小割)
    BZOJ 3993 Luogu P3324 [SDOI2015]星际战争 (最大流、二分答案)
    BZOJ 3277 串 & BZOJ 3473 字符串 (广义后缀自动机、时间复杂度分析)
    BZOJ 2806 Luogu P4022 [CTSC2012]Cheat (广义后缀自动机、DP、二分、单调队列)
    Mongodb的聚合和管道
    Mongodb文档查询
    Mongodb的基本操作-数据库 集合 文档的增删改查
    Linux下Mongodb的安装
    mongdb的优势和不足
  • 原文地址:https://www.cnblogs.com/dengchaojie/p/7346645.html
Copyright © 2011-2022 走看看