一,效果图。

二,工程图。

三,代码。

RootViewController.h

#import <UIKit/UIKit.h>

@interface RootViewController : UIViewController
<UITableViewDelegate,UITableViewDataSource,UISearchDisplayDelegate,UISearchBarDelegate>
{
UITableView * tableview;
NSMutableArray * Aarray;
UISearchBar * searchBar;
UISearchDisplayController *searchControl;
}
@end

RootViewController.m

#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
} - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view. //初始化背景图
[self initBackGroundView];
}
#pragma -mark -functions
-(void)initBackGroundView
{
Aarray = [[NSMutableArray alloc] initWithObjects:@"+",@"我",@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X",@"Y",@"Z",@"#",nil]; //tableView
tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 460-44-10-10-20) style:UITableViewStylePlain];
tableview.tag = 101;
tableview.delegate = self;
tableview.dataSource = self;
[self.view addSubview:tableview]; //searchView
searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
tableview.tableHeaderView = searchBar;
searchBar.showsScopeBar = YES;
searchBar.placeholder = @"在全部关注中搜索..."; //搜索的时候会有左侧滑动的效果
searchControl = [[UISearchDisplayController alloc]initWithSearchBar:searchBar contentsController:self];
searchControl.delegate = self;
searchControl.searchResultsDataSource = self;
searchControl.searchResultsDelegate = self; }
#pragma -mark -searchbar
-(void)searchBar:(UISearchBar *)searchBar selectedScopeButtonIndexDidChange:(NSInteger)selectedScope
{
;
}
#pragma -mark -UITableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0) {
return 1;
}
return 100;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 40.0;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString * strID = @"ID";
UITableViewCell * cell = [tableview dequeueReusableCellWithIdentifier:strID];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:strID];
} if (indexPath.section == 0 && indexPath.row == 0) {
cell.textLabel.text = @"找朋友";
}else if(indexPath.section ==1 && indexPath.row == 0){
cell.textLabel.text=@"row";
}
return cell;
} -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if (section == 1) {
return @"我的资料";
}
return nil;
}
-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
return [NSArray arrayWithObjects:UITableViewIndexSearch,@"+",@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X",@"Y",@"Z",@"#", nil];
} - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

最新文章

  1. MySQL frm+ibd文件还原data的办法【数据恢复】
  2. WinPcap4.13无法安装解决方法
  3. 获取表单选中的值(利用php和js两种方式)
  4. Linux:常用快捷键
  5. Rapha&#235;l 是一个小型的 JavaScript 库,用来简化在页面上显示向量图的工作。你可以用它在页面上绘制各种图表、并进行图片的剪切、旋转等操作。
  6. Uva 10007 / HDU 1131 - Count the Trees (卡特兰数)
  7. 【转】Android菜单详解——理解android中的Menu--不错
  8. (转)IIS7 下部署Asp.net应用
  9. 剑指offer ------ 刷题总结
  10. 手机自动化测试:appium源码分析之bootstrap四
  11. OpenCV 读取视频 多种方式
  12. 怎么选择公司???MVC加jquery-easyui 后端工程师
  13. Android Studio 查看手机CPU信息
  14. python3之迭代器&amp;生成器
  15. 解决ubuntu系统root用户下Chrome无法启动问题
  16. LocalBroadcastManager—创建更高效、更安全的广播
  17. spring Ioc容器之使用XML配置Bean
  18. javaMail实现收发邮件(四)
  19. BSGS及扩展BSGS总结(BSGS,map)
  20. [视频]K8飞刀--WinRAR远程代码执行漏洞利用视频

热门文章

  1. JS魔法堂:再识IE的内存泄露
  2. Open Audio Library
  3. 【转】sql server 获取每一个类别中值最大的一条数据
  4. 【转载】CSS Sticky Footer: 完美的CSS绝对底部
  5. 控件使用经验-MVP模式+控件封装
  6. 组件Newtonsoft.Json实现object2json转换
  7. 如何安装node.js支持插件
  8. virtualenvwrapper安装使用
  9. [转]Dcloud App离线本地存储方案
  10. javascript 异步模块加载 简易实现