开始研究大数据方面了|开始研究大数据方面了,留下我最近的记录(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
【开始研究大数据方面了|开始研究大数据方面了,留下我最近的记录(Swift各种转场和搜索控件的使用)】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

    推荐阅读