//
// 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. sorting--codility

    lesson 6: sorting 1. Distinct 2. Triangle 2. MaxProductOfThree 4. NumberOfDiscIntersections lesson 6 ...

  2. angularJS的ng-repeat-start

    使用angularJS的同学对ng-repeat都不会陌生,他是用来进行数据循环的,一般用于数组或者对象.但是今天我们用到了一个ng-repeat-start. ng-repeat-start,与ng ...

  3. hBuilder培训资源视频教程汇总

    DCloud对开发者的学习支持分3个层面:官方文档.三方专业培训.网友经验分享 DCloud的精力主要在做产品,配套的文档也会一直完善好.但专业的培训还不是DCloud能做好的,在HTML5中国产业联 ...

  4. 使用sublime text3手动安装插件

    众所周知,由于网络问题,使用install package可能会连不上服务器,这时候就不得不手动安装插件了. 其实sublime安装插件的原理就是当你搜索一个插件并安装的时候,它回去github找到这 ...

  5. 在eclipse中使用mybatis-generator自动创建代码

    1.eclipse中安装插件,地址:http://mybatis.googlecode.com/svn/sub-projects/generator/trunk/eclipse/UpdateSite/ ...

  6. 机器学习中的python常用函数

    glob模块 说明: 1.glob是python自己带的一个文件操作相关模块,用它可以查找符合自己目的的文件,就类似于Windows下的文件搜索, 支持通配符操作 *.?.[] 这三个通配符,*代表0 ...

  7. phpcms 实现动态价格

    什么是动态价格(自命名)?——  一般来说商品有个固定的价格,随着节假日或者促销活动可能会发生价格变化,结束后又恢复原价,如果每次价格变化都需要修改价格,那么不仅在时间上不好把握,也需要消耗更多的人力 ...

  8. <转>cocos2d-x学习笔记(五)仿真树叶飘落效果的实现(精灵旋转、翻转、钟摆运动等综合运用)

    转载自ufolr的博客 原文连接:http://blog.csdn.net/ufolr/article/details/7624851 最近项目中需要一个落叶的效果,本来想用粒子特效来实现,但是几经调 ...

  9. 分析学习MYSQL源代码需要哪些方面的知识呢?

    分析学习MYSQL源代码需要哪些方面的知识呢? 哪些书籍或网站对这方面有帮助呢? 60d

  10. MVVMLight介绍以及在项目中的使用

    http://www.des8.me/detail-1822826.html 一.MVVM 和 MVVMLight介绍 MVVM是Model-View-ViewModel的简写.类似于目前比较流行的M ...