根据首字母查找单词
来源:互联网 发布:校验md5码软件 编辑:程序博客网 时间:2024/05/16 00:28
将MainTableViewController作为导航控制器的根控制器
_window = [[UIWindowalloc] initWithFrame:[UIScreenmainScreen].bounds];
_window.backgroundColor = [UIColorwhiteColor];
[_windowmakeKeyAndVisible];
MainTableViewController *mainViewCtrl = [[MainTableViewControlleralloc] initWithStyle:UITableViewStylePlain];
UINavigationController *navCtrl = [[UINavigationControlleralloc] initWithRootViewController:mainViewCtrl];
_window.rootViewController = navCtrl;
#import <UIKit/UIKit.h>
@interface MainTableViewController :UITableViewController<UITableViewDelegate>{
UITableView *_tableView;//表视图
NSArray *array;
NSMutableArray *_date;
}
#import "MainTableViewController.h"
@interface MainTableViewController ()
@end
@implementation MainTableViewController
- (void)viewDidLoad {
[superviewDidLoad];
array = [UIFontfamilyNames];
_date = [NSMutableArrayarrayWithArray:array];
//设置导航栏
self.navigationController.navigationBar.barStyle =UIBarStyleBlackOpaque;
//创建输入框视图
UITextField *textfield = [[UITextFieldalloc] initWithFrame:CGRectMake(85,0, 190, 30)];
textfield.backgroundColor = [UIColorwhiteColor];
//输入框的圆角
textfield.layer.cornerRadius =5;
[textfield addTarget:selfaction:@selector(textfield:)forControlEvents:UIControlEventEditingChanged];
[self.navigationController.navigationBaraddSubview:textfield];
#pragma mark - Table view data source
//设置单元格
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _date.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *iden =@"cell";
UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:iden ];
if (cell == nil) {
cell = [[[UITableViewCellalloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:iden] autorelease];
}
cell.textLabel.text =_date[indexPath.row];
return cell;
}
- (void)textfield:(UITextField *)textfield{
NSString *text = textfield.text;
if ([text length] ==0) {
_date = [[NSMutableArrayarrayWithArray:array]retain];
[self.tableViewreloadData];
return;
}
// 过滤条件
NSString *p = [NSStringstringWithFormat:@"SELF LIKE[c] '%@*'",text];
// 谓词过滤
NSPredicate *predicate = [NSPredicatepredicateWithFormat:p];
NSArray *arr = [arrayfilteredArrayUsingPredicate:predicate];
_date = [[NSMutableArrayarrayWithArray:arr]retain];
//刷新表视图
[self.tableViewreloadData];
}
- 根据首字母查找单词
- 根据首字母自动查找功能的实现
- 根据拼音首字母匹配汉字(电话本联系人查找)
- 单词首字母大写 JavaScript
- 字符串单词首字母大写
- C#-单词首字母大写
- 单词首字母转换大小写
- 单词首字母大写
- JS首字母大写-每个单词首字母大写
- 根据汉字取首字母
- 根据拼音首字母查询
- 根据汉子获取首字母
- 查找单词
- 统计单词数目及单词首字母大写
- C 单词首字母大写&统计单词个数
- SQLServer设置单词首字母大写
- 字符串每个单词首字母大写
- 转换每个单词首字母大写
- 适配器模式adapter
- Access denied for user 'root'@'localhost' (using password:YES) 解决方案
- [algorithm]2月29日
- SDUST SingleTest A(15.4.3)
- myeclipse10 js报错 jslib报错
- 根据首字母查找单词
- P122第21题
- UIView
- (7-2)hive参数配置使用
- Career Classification – Possible Career Options
- VS2010/MFC编程入门之二十一(常用控件:编辑框Edit Control)
- php的mysqli_result类
- hdu~3706(单调队列)
- (7-3)hive的脚本执行