//
// 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. php如何获取服务器所在的时区

    //获取默认时区echo date_default_timezone_get(); //将时区设置为中国date_default_timezone_set("PRC"); //将时 ...

  2. [C++ Primer] 第3章: 字符串, 向量和数组

    标准库类型string string初始化 string s2(s1); string s2 = s1; string s3("value"); string s3 = " ...

  3. 学习笔记之C++ Primer中文版(第五版)

    非常权威系统的语言书,正好学习下C++11内容. C++ Primer_百度百科 http://baike.baidu.com/link?url=YLvDJE9w3CjGp3eQwjuXYKUZs7v ...

  4. [Android] 开发第五天

    布之前开发的 Android 电话拨号器 Android-Studio 已经带了发布菜单, Build -> Generate Signed APK 进入发布界面 我们新增一个证书,或者使用已有 ...

  5. Hibernate中get()和load()的区别

    Hibernate中根据Id单条查询获取对象的方式有两种,分别是get()和load(),来看一下这两种方式的区别. 1. get() 使用get()来根据ID进行单条查询: User user=se ...

  6. Maven的依赖机制介绍

    以下内容引用自https://ayayui.gitbooks.io/tutorialspoint-maven/content/book/maven_manage_dependencies.html: ...

  7. MySQL 存储配置

  8. JavaScript之深拷贝&浅拷贝

    深拷贝&浅拷贝,说起来都明白,但是说不出所以然.今天就系统的整理下思绪,一点点的将其分析出所以然 废话不多说 浅拷贝 简单的说就是一个值引用,学生时代接触过编程的人都应该了解过指针,浅拷贝可以 ...

  9. Advanced Simulation Library(ASL)&& An adaptive and distributed-memory parallel implementation of the immersed boundary (IB) method (IBAMR)

    How to install asl and ibamr tools: ASL 和 IBAMR 都是有限元分析的工具,流体力学等,ASL可以使用GPU加速计算, 主机配置,i7 6代,1060, 32 ...

  10. 使用打印方法时,要先引用命名空间: Using System.Drawing.Pringing

    使用打印方法时,要先引用命名空间: Using System.Drawing.Pringing PrintDocument类的重要属性和方法:属性:DocumentName  设置打印文档时要显示的文 ...