//
// 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的更多相关文章

  1. iOS--- UITableView + UISearchDisplayController - - - - -实现搜索功能

    iOS中UISearchDisplayController用于搜索,搜索栏的重要性我们就不说了,狼厂就是靠搜索起家的,现在越来越像一匹没有节操的狼,UC浏览器搜索栏现在默认自家的神马搜索,现在不管是社 ...

  2. iOS--UISearchBar和UISearchDisplayController

    UISearchBar继承自UIView.UIResponder.NSObject 属性: autocapitalizationType————自动对输入文本对象进行大小写设置(包含4种类型,但是有时 ...

  3. UISearchBar和 UISearchDisplayController的使用

    感觉好多文章不是很全面,所以本文收集整合了网上的几篇文章,感觉有互相补充的效果. 如果想下载源码来看:http://code4app.com/search/searchbar .本源码与本文无关 1. ...

  4. UISerachBar / UISearchDisplayController

    1. UISerachBar 继承与UIView, 包含uitextfield, 并且实现了uitextfielddelegate代理的主要内容 含有取消按钮, 默认不显示 2. UISerachDi ...

  5. 如何在UINavigationBar上添加UISearchBar以及UISearchDisplayController的使用 --OC --iOS

    那我们开始吧,下面是Sely写的一个Demo,分享给大家. 新建一个项目, UISearchDisplayController 的 displaysSearchBarInNavigationBar太死 ...

  6. UISearchDisplayController简单使用

    最近在做一个简单的app入门,中间有一个页面用到了搜索框,本来以为很简单的控件,没想到用到的时候才发现很麻烦. 搜索框使用过程大约有以下几个状态:不活跃-活跃-输入关键词-根据关键词动态列出相关结果- ...

  7. iOS 用UISearchDisplayController实现查找功能

    UISearchDisplayController是iOS中用于处理搜索功能的控制器,此控制器需要和UISearchBar结合使用 示例代码如下: // // WKRootViewController ...

  8. Swift - 带结果列表的搜索条(UISearchDisplayController)的用法

    (注:自iOS8起,苹果便废弃UISearchDisplayController的使用,改为使用UISearchController来实现类似功能,可参考我的另一篇文章“Swift - 使用UISea ...

  9. 点击搜索取消UISearchDisplayController的搜索状态

    一般,我们用到UISearchDisplayController的时候,都是须要对一个数据源进行刷选,在UISearchDisplayController自带的tableView中展示出来,然后点击退 ...

  10. iOS UISearchDisplayController学习笔记

    UISearchDisplayController和UISearchBar一起使用用来管理UISearchBar和搜索结果的展示.UISearchDisplayController提供了显示搜索结果的 ...

随机推荐

  1. 显示Deprecated: Assigning the return value of new by reference is deprecated in解决办法

    很多朋友的php程序当php的版本升级到5.3以后,会出现”Deprecated: Assigning the return value of new by reference is deprecat ...

  2. 小米开源监控open-falcon

    小米开源监控系统Open-Falcon安装使用笔记 07net01.com 发布于 2016-10-25 18:42:03 分类:IT技术 阅读(88) 评论 前言 近期爆出Zabbix有严重bug, ...

  3. unity里面的gameobject和transform的关系

    一切都是物体(gameobject),而transform是物体的一个基本属性类,包含位置,旋转,缩放,三个基本属性,两者之间可以互相转换 查找物体,建议用transform,GameObject无法 ...

  4. iSCSI 协议

    iSCSI 协议 iSCSI协议结构 如同任何一个协议一样,iSCSI也有一个清晰的层次结构,根据OSI模型,iSCSI的协议栈自顶向下一共可以分为五层,如图所示: SCSI层:根据应用发出的请求建立 ...

  5. 汇编_指令_INC

    加1指令 INC指令功能:目标操作数+1 INC指令只有1个操作数,它将指定的操作数的内容加1,再将结果送回到该操作数.INC指令将影响SF,AF,ZF,PF,OF标志位,但是不影响CF标志位. IN ...

  6. mysql5.7.12/13在安装新实例时报错:InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero

    .bin/mysqld --initialize-insecure --basedir=xxx --datadir=xxx 然后 .bin/mysqld_safe --defaults-file=xx ...

  7. FancyButtons一个漂亮按钮的库

      一个功能强大且全面的按钮控件,是目前我见过的最好使的按钮. 支持给按钮添加图标,并且可通过属性设置手指按钮的效果,不需要在写<selector>文件. 项目地址:https://git ...

  8. C# mysql 连接Apache Doris

    前提:  安装mysql odbc驱动程序,目前只不支持8.0的最新版本驱动,个人使用的是5.1.12的驱动(不支持5.2以上版本),下载地址为: x64: https://cdn.mysql.com ...

  9. 使用Fiddler对Android手机的应用数据进行抓包分析

    文章源自: http://blog.csdn.net/zshq280017423/article/details/8928616/ 对于Android开发的同事最头疼的事情莫过于真机抓包,然后Fidd ...

  10. 通过 Lua 扩展 NGINX 实现的可伸缩的 Web 平台OpenResty®

    OpenResty® 是一个基于 Nginx 与 Lua 的高性能 Web 平台,其内部集成了大量精良的 Lua 库.第三方模块以及大多数的依赖项.用于方便地搭建能够处理超高并发.扩展性极高的动态 W ...