贴一段我很久以前写的小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中的内容的更多相关文章

  1. iOS中的两种搜索方式UISearchDisplayController和UISearchController

    大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 以前iOS的搜索一般都使用UISearchDisplayCon ...

  2. iOS中利用UISearchBar实现搜索

    先把源码贴出来 https://github.com/losedMemory/ZSSearchBar   这是我在github上写的一个Demo,大家可以看看 在大多数app中都会用到搜索功能,那么搜 ...

  3. iOS学习之NSPredictae及搜索框的实现

    NSPredicate Predicate 即谓词逻辑, Cocoa框架中的NSPredicate用于查询,作用是从数据堆中根据条件进行筛选.计算谓词之后返回的结果永远为BOOL类型的值,当程序使用谓 ...

  4. iOS 9之应用内搜索(CoreSpotlight)API

    金田(github 示例源码) 前言 在iOS9之前我们只能使用Spotlight来搜索应用名称来打开指定App,而其他的内容都是提供给系统使用(信息,联系人,邮件等).在iOS9以后Apple允许开 ...

  5. ios下虚拟键盘出现"搜索"字样

    最近在开发过程中,发现用户输入想要检索的内容,弹出虚拟键盘,在安卓机上虚拟键盘最右下角会有‘搜索’字样,而ios上虚拟键盘最右下角只有‘换行’字样, 这样用户体验就会大打折扣. 安卓机上虚拟键盘 io ...

  6. 对图片进行索引,存入数据库sqlite3中,实现快速搜索打开

    对图片进行索引,存入数据库中,实现快速搜索打开    这个任务分为两步: 第一步:建立索引 import os import shutil import sqlite3 # 扫描函数,需扫描路径目录处 ...

  7. WCF 在VS中,添加服务引用,地址输入http://ip/Service.svc,点击前往,提示错误,内容如下:

    WCF的service端的webconfig如下: <?xml version="1.0"?> <configuration> <system.ser ...

  8. LoadRunner如何获得参数化中每个关键字的搜索响应时间

    LoadRunner如何获得参数化中每个关键字的搜索响应时间 在测试搜索引擎时我们一般采用大量的搜索关键字,有时有必要了解在并发访问的情况下每个关键字的响应时间,一般如果不对脚本进行处理的话你可以获得 ...

  9. 如何从统计中批量获取BD搜索关键词及对应的入口页面?

    前面我们介绍了通过cnzz的访问明细获取到搜索关键词及对应的入口页面,但是从BD搜索进来的关键词无法完整显示,只能呈现一些bd图片搜索的关键词,这是因为百度宣布从去年5月开始逐渐取消了referer关 ...

随机推荐

  1. oracle删除用户及表空间,导入用户和数据

    drop user xxx cascade; drop tablespace xxx including contents and datafiles; create tablespace xxx d ...

  2. phpstorm version 2016.2 License Server激活

    phpstorm version 2016.2 License Server激活 安装后,在激活的时候选择 license server; 输入如下地址激活: http://jetbrains.ten ...

  3. 【jq】c#零基础学习之路(5)自己编写简单的Mylist<T>

    public class MyList<T> where T : IComparable { private T[] array; private int count; public My ...

  4. 刷题ING...

    我用codeVS刷题.. 努力准备!!

  5. jquery $.ajax()方法

    $(function(){ $('#send').click(function(){ $.ajax({ /* *type:要求为String类型的参数,请求方式(post或get)默认为get. *注 ...

  6. C/C++文字常量与常变量的概念与区别 分类: C/C++ 2015-06-10 22:56 111人阅读 评论(0) 收藏

    以下代码使用平台是Windows 64bits+VS2012. 在C/C++编程时,经常遇到以下几个概念:常量.文字常量.符号常量.字面常量.常变量.字符串常量和字符常量,网上博客资料也是千篇千律,不 ...

  7. Quant的笑话

    Q) Why was the FX quant so unlucky with the ladies?A) Because he always kept his dates short. Q) Why ...

  8. mouseover事件与mouseenter事件的区别

    不论鼠标指针穿过被选元素或其子元素,都会触发 mouseover 事件.对应mouseout 只有在鼠标指针穿过被选元素时,才会触发 mouseenter 事件.对应mouseleave 被触发的 M ...

  9. build配置

     buildTypes {         debug {             // 显示Log             buildConfigField "boolean", ...

  10. Android单元测试实践

    为什么要写单元测试 首先要介绍为什么蘑菇街支付金融这边会采用单元测试的实践.说起来比较巧,刚开始的时候,只是我一个人会写单元测试.后来老板们知道了,觉得这是件 很有价值的事情,于是就叫我负责我们组的单 ...