UISearchDisplayController
//
// FirstViewController.swift
// SearchDisplayDemo
//
// Created by Bruce Lee on 24/12/14.
// Copyright (c) 2014 Dynamic Cell. All rights reserved.
// import UIKit class FirstViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UISearchDisplayDelegate, UISearchBarDelegate { @IBOutlet weak var tableView: UITableView!
var searchBar: UISearchBar!
var searchController: UISearchDisplayController!
var maskView: UIVisualEffectView! override func viewDidLoad() {
super.viewDidLoad() self.searchBar = UISearchBar(frame: CGRectMake(, , UIScreen.mainScreen().bounds.width, ))
searchBar.delegate = self;
self.tableView.tableHeaderView = self.searchBar
self.searchController = UISearchDisplayController(searchBar: self.searchBar, contentsController: self)
self.searchController.delegate = self
var blurEffect = UIBlurEffect(style: .Light)
maskView = UIVisualEffectView(effect: blurEffect)
maskView.frame = UIScreen.mainScreen().bounds var testLabel = UILabel(frame: CGRectMake(, , , ))
testLabel.text = "hello world"
maskView.addSubview(testLabel)
} // MARK: - UISearchBar delegate
func searchBarShouldBeginEditing(searchBar: UISearchBar) -> Bool {
println("search")
// self.searchDisplayController?.searchResultsTableView.backgroundView = searchBackgroundView
self.view.addSubview(maskView)
return true
} // MARK: - UISearchDisplayController delegate
func searchDisplayController(controller: UISearchDisplayController, willHideSearchResultsTableView tableView: UITableView) {
maskView.removeFromSuperview()
} func searchDisplayControllerWillEndSearch(controller: UISearchDisplayController) {
println("")
maskView.removeFromSuperview()
} func searchDisplayControllerDidEndSearch(controller: UISearchDisplayController) {
println("")
} // MARK: - UITableView delegate & datasour func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return
} func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return
} func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("Cell") as? UITableViewCell
if cell == nil {
cell = UITableViewCell(style: .Default, reuseIdentifier: "Cell")
}
if indexPath.row % == {
cell?.contentView.backgroundColor = UIColor.blueColor()
}
else{
cell?.contentView.backgroundColor = UIColor.greenColor()
}
cell?.textLabel?.text = "\(indexPath.row)" return cell!
} override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
UISearchDisplayController的更多相关文章
- iOS--- UITableView + UISearchDisplayController - - - - -实现搜索功能
iOS中UISearchDisplayController用于搜索,搜索栏的重要性我们就不说了,狼厂就是靠搜索起家的,现在越来越像一匹没有节操的狼,UC浏览器搜索栏现在默认自家的神马搜索,现在不管是社 ...
- iOS--UISearchBar和UISearchDisplayController
UISearchBar继承自UIView.UIResponder.NSObject 属性: autocapitalizationType————自动对输入文本对象进行大小写设置(包含4种类型,但是有时 ...
- UISearchBar和 UISearchDisplayController的使用
感觉好多文章不是很全面,所以本文收集整合了网上的几篇文章,感觉有互相补充的效果. 如果想下载源码来看:http://code4app.com/search/searchbar .本源码与本文无关 1. ...
- UISerachBar / UISearchDisplayController
1. UISerachBar 继承与UIView, 包含uitextfield, 并且实现了uitextfielddelegate代理的主要内容 含有取消按钮, 默认不显示 2. UISerachDi ...
- 如何在UINavigationBar上添加UISearchBar以及UISearchDisplayController的使用 --OC --iOS
那我们开始吧,下面是Sely写的一个Demo,分享给大家. 新建一个项目, UISearchDisplayController 的 displaysSearchBarInNavigationBar太死 ...
- UISearchDisplayController简单使用
最近在做一个简单的app入门,中间有一个页面用到了搜索框,本来以为很简单的控件,没想到用到的时候才发现很麻烦. 搜索框使用过程大约有以下几个状态:不活跃-活跃-输入关键词-根据关键词动态列出相关结果- ...
- iOS 用UISearchDisplayController实现查找功能
UISearchDisplayController是iOS中用于处理搜索功能的控制器,此控制器需要和UISearchBar结合使用 示例代码如下: // // WKRootViewController ...
- Swift - 带结果列表的搜索条(UISearchDisplayController)的用法
(注:自iOS8起,苹果便废弃UISearchDisplayController的使用,改为使用UISearchController来实现类似功能,可参考我的另一篇文章“Swift - 使用UISea ...
- 点击搜索取消UISearchDisplayController的搜索状态
一般,我们用到UISearchDisplayController的时候,都是须要对一个数据源进行刷选,在UISearchDisplayController自带的tableView中展示出来,然后点击退 ...
- iOS UISearchDisplayController学习笔记
UISearchDisplayController和UISearchBar一起使用用来管理UISearchBar和搜索结果的展示.UISearchDisplayController提供了显示搜索结果的 ...
随机推荐
- 两个不错点电影ED2000资源
http://simplecd.me/ http://www.ed2000.com/ http://www.2tu.cc/ http://www.mp4ba.com/ http://www.ddyy. ...
- oracle数据库启动时出现ORA-01157和ORA-01110问题
sql>startup mount; sql>alter database open; RA-01157: 无法标识/锁定数据文件 10 - 请参阅 DBWR 跟踪文件ORA-01110: ...
- Spring Security3十五日研究(转载)
前言 南朝<述异记>中记载,晋王质上山砍柴,见二童子下棋,未看完,斧柄已烂,下山回村,闻同代人都去世了,自已还未变老. 因此发出“山中方一日,世上几千年” 的慨叹.原文寥寥几笔,读来 ...
- 阿里云OSS linux使用备忘录
ossutil config example: accessKeyId = "AccessKeyId"; accessKeySecret = "AccessKeySecr ...
- Makefile编写 三 伪目标的作用
本节我们讨论一个Makefile中的一个重要的特殊目标:伪目标. 伪目标是这样一个目标:它不代表一个真正的文件名,在执行make时可以指定这个目标来执行其所在规则定义的命令,有时我们也可以将一个伪目标 ...
- Java通过匿名类来实现回调函数
在C语言中,函数名可以当做函数指针传递给形参从而实现回调 void f1() { printf("f1()\n"); } void f2() { printf("f2() ...
- 添加APP右上角数字提醒标识
mui.plusReady(function() { plus.nativeUI.closeWaiting(); mui.currentWebview.show(); //1.设置app右上角数字提醒 ...
- XSS获取cookie并利用
获取cookie利用代码cookie.asp <html> <title>xx</title> <body> <%testfile = Serve ...
- Java 中的包装类
Java 中的包装类 相信各位小伙伴们对基本数据类型都非常熟悉,例如 int.float.double.boolean.char 等.基本数据类型是不具备对象的特性的,比如基本类型不能调用方法.功能简 ...
- 汇编_指令_SHL、SHR、SAL、SAR、ROL、ROR、RCL、RCR
;SHL(Shift Left): 逻辑左移 ;SHR(Shift Right): 逻辑右移 ;SAL(Shift Arithmetic Left): 算术左移 ;SAR(Shif ...