開始研究大數據方面了,留下我最近的記錄(Swift各種轉場和搜索控件的使用)

一、彈出窗口/底部窗口 didSelectRowat

1.Let xxx = UIAlertController(title: “”, message: “”, preferredStyle: )

2.let xxx = UIAlertAction(title: “”, style: .alert/.actionSheet, handler: )

3.xxx.addAction(xxx)

4.self.present(xxxs, animated:true, completion: nil)

二、右劃菜單 editActionsForRowAt

1.let xxx= UITableViewRowAction(style: , title: , handler:)

2.對handler閉包添加一種的兩種方式

3.刪除部分的源代碼

三、轉場傳值

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

if segue.identifier == “xxxx” {

let xxx = segue.destination as! xxx

Xxx =? sender as! Xxx

}

}

四、模態化轉場

@IBAction func close(segue: UIStoryboardSegue) {

Let xxx = segue.source as! xxx

}

五、模態化轉場傳值

performSegue(withIdentifier: "areaComment", sender: sender)

六、刪除時候一定先刪除底層變量 在可視化部分刪除

七、退場 dismiss()

八、子頁面導航欄返回

let leftBarBtn = UIBarButtonItem(title: "返回", style: .plain, target: self,

action: #selector(backToPrevious))


tableViewCell 搜索相關數據

1.定義數組存放查找到的數據

var searchResults: [Area] = []

2.添加一個搜索依據方法

func searchFilter(text: String) {

searchResults = areas.filter({ (area) -> Bool in

return area.name!.localizedCaseInsensitiveContains(text)

})

}

3.執行搜索方法

func updateSearchResults(for searchController: UISearchController) {

if let text = searchController.searchBar.text {

searchFilter(text: text)

tableView.reloadData()

}

}

4.根據搜索欄是否被激活顯示數據行數

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

// #warning Incomplete implementation, return the number of rows

return searchController.isActive ? searchResults.count : areas.count

}

5.根據搜索欄是否被激活選擇相應的顯示數據

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

let area = searchController.isActive ? searchResults[indexPath.row] : areas[indexPath.row]

}

6.根據搜索欄是否被激活選擇Cell是否能修改

override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {

return !searchController.isActive

}

7.如果有轉場傳值的話需要相應更改

搜索條美化

// 搜索條美化之后背景不變黑,且可以點擊搜索數據

searchController.searchBar.dimsBackgroundDuringPresentation = false

// 搜索條占位符

searchController.searchBar.placeholder = ""

// 搜索條提示

searchController.searchBar.prompt

// 搜索條前景色

searchController.tintColor

// 搜索條主題樣式(默認.Prominent(突出) .Minimal(透明))

searchController.searchBar.searchBarStyle

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容