ios中,在SearchBar里面搜索内容,可根据内容来查找所需的信息资源,可获得SearchBar中的内容
贴一段我很久以前写的小demo,你们就明白了,是把textField套在alertView里的
@interface ViewController : UIViewController <UIAlertViewDelegate, UITextFieldDelegate>{
UILabel *la;
UITextField *myTextField;
} @implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad]; la = [[UILabel alloc] init];
la.Frame = CGRectMake(10, 150,300,30);
la.backgroundColor = [UIColor clearColor];
la.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
la.text = @"initLabel";
la.textAlignment = UITextAlignmentCenter;
la.shadowColor = [UIColor colorWithWhite:0.0f alpha:0.75f];
la.shadowOffset = CGSizeMake(0.0f, 5.0f); la.textColor = [UIColor greenColor]; [self.view addSubview:la]; UIButton *alartBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
alartBtn.frame = CGRectMake(110, 50, 50, 50);
alartBtn.backgroundColor = [UIColor clearColor];
[alartBtn setTitle:@"alart" forState:UIControlStateNormal];
[alartBtn addTarget:self action:@selector(alartShow:) forControlEvents:UIControlEventTouchUpInside];
[alartBtn setAlpha:1.0];
[self.view addSubview:alartBtn]; }
-(void)alartShow:(id)sender{ UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Title" message:@" " delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"OK", nil];
[alert show];
[alert release]; myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)]; [myTextField setBackgroundColor:[UIColor whiteColor]];
[alert addSubview:myTextField];
[myTextField setDelegate:self]; [myTextField addTarget:self action:@selector(onTextFieldChanged:forEvent:) forControlEvents:UIControlEventEditingChanged]; NSLog(@"myTextField.text:%@", myTextField.text); } - (void)alertView: (UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex {
{ NSLog(@"%@", myTextField.text);
la.text = myTextField.text; }
} - (void)alertView:(UIAlertView *)alert didDismissWithButtonIndex:(NSInteger)buttonIndex{
if (buttonIndex == [alert cancelButtonIndex]) {
close(0);
} } - (void) onTextFieldChanged:(id)sender forEvent:(UIEvent *)event{ NSLog(@"%@", myTextField.text);
}
摘出来的,大概意思应该已经有了,有用的自己在看下。。。欢迎技术交流,彼此进步。。谢谢。。
ios中,在SearchBar里面搜索内容,可根据内容来查找所需的信息资源,可获得SearchBar中的内容的更多相关文章
- iOS中的两种搜索方式UISearchDisplayController和UISearchController
大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 以前iOS的搜索一般都使用UISearchDisplayCon ...
- iOS中利用UISearchBar实现搜索
先把源码贴出来 https://github.com/losedMemory/ZSSearchBar 这是我在github上写的一个Demo,大家可以看看 在大多数app中都会用到搜索功能,那么搜 ...
- iOS学习之NSPredictae及搜索框的实现
NSPredicate Predicate 即谓词逻辑, Cocoa框架中的NSPredicate用于查询,作用是从数据堆中根据条件进行筛选.计算谓词之后返回的结果永远为BOOL类型的值,当程序使用谓 ...
- iOS 9之应用内搜索(CoreSpotlight)API
金田(github 示例源码) 前言 在iOS9之前我们只能使用Spotlight来搜索应用名称来打开指定App,而其他的内容都是提供给系统使用(信息,联系人,邮件等).在iOS9以后Apple允许开 ...
- ios下虚拟键盘出现"搜索"字样
最近在开发过程中,发现用户输入想要检索的内容,弹出虚拟键盘,在安卓机上虚拟键盘最右下角会有‘搜索’字样,而ios上虚拟键盘最右下角只有‘换行’字样, 这样用户体验就会大打折扣. 安卓机上虚拟键盘 io ...
- 对图片进行索引,存入数据库sqlite3中,实现快速搜索打开
对图片进行索引,存入数据库中,实现快速搜索打开 这个任务分为两步: 第一步:建立索引 import os import shutil import sqlite3 # 扫描函数,需扫描路径目录处 ...
- WCF 在VS中,添加服务引用,地址输入http://ip/Service.svc,点击前往,提示错误,内容如下:
WCF的service端的webconfig如下: <?xml version="1.0"?> <configuration> <system.ser ...
- LoadRunner如何获得参数化中每个关键字的搜索响应时间
LoadRunner如何获得参数化中每个关键字的搜索响应时间 在测试搜索引擎时我们一般采用大量的搜索关键字,有时有必要了解在并发访问的情况下每个关键字的响应时间,一般如果不对脚本进行处理的话你可以获得 ...
- 如何从统计中批量获取BD搜索关键词及对应的入口页面?
前面我们介绍了通过cnzz的访问明细获取到搜索关键词及对应的入口页面,但是从BD搜索进来的关键词无法完整显示,只能呈现一些bd图片搜索的关键词,这是因为百度宣布从去年5月开始逐渐取消了referer关 ...
随机推荐
- CodeForces 239A. Triangle
Link: http://codeforces.com/contest/407/problem/A 给定直角三角形的2个直角边a,b.求在直角坐标系中,是否存在对应的直角三角形,使得三个定点都在整点 ...
- 分享一个ruby网站 | 菜鸟教程
http://www.runoob.com/ruby/ruby-tutorial.html 分享一个ruby网站.
- FZU-2075 Substring(后缀数组)
Description Given a string, find a substring of it which the original string contains exactly n such ...
- SSH开源框架的优缺点
js+servlet+javabean的开发模式需要写很多的重复代码,比如固定的doGet()方法,而且它的控制跳转不灵活,往往一个问题处理需要两个.java文件,而且当采用MVC模式开发时有很大的耦 ...
- codeMirror的简单使用,js比较文本差异(标注出增删改)
最近项目需要使用比较文本的差异的功能,在同事的推荐下,使用js脚本来比较,所以codeMirror变成了选择. 当然codeMirror中有其他功能,比较文本差异的只是其中一个功能,本人不在此做介绍, ...
- 未能加载文件或程序集 Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad
没有 microsoft.web.infrastructure.dll 文件. 解决方式: ,第一种:在所发布的项目文件里面的 bin 文件目录下,添加 microsoft.web.infrastru ...
- if you end up with a boring miserable life
- MySQL binlog的格式解析
我搜集到了一些资料,对理解代码比较有帮助. 在头文件中binlog_event.h中,有描述 class Log_event_header class Log_event_footer 参见[Myst ...
- 影响性能的关键部分-ceph的osd journal写
在前面一篇文章中,我们看到,当使用filestore时,osd会把磁盘分成data和journal两部分.这主要是为了支持object的transaction操作.我的想法是,ceph需要具有数据保护 ...
- JQuery 1.*速成版之二
过滤选择器简称:过滤器.它其实也是一种选择器,而这种选择器类似与 CSS3(http://t.mb5u.com/css3/)里的伪类,可以让不支持 CSS3 的低版本浏览器也能支持.和常规选择器一样, ...