带索引的tableView
带索引的tableView
一,效果图。

二,工程图。

三,代码。
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.
}
复制代码
带索引的tableView的更多相关文章
- jQuery仿3D旋转木马效果插件(带索引按钮)
项目中需要用到旋转木马效果,但是我在网上找的插件,基本都是不带按钮或者只是带前后按钮的,而项目要求的是带索引按钮,也就是说有3张图片轮播,对应的要有3个小按钮,点击按钮,对应的图片位于中间位置.于是就 ...
- Android带索引联系人列表
网上Android联系人列表的样例也非常多,都和微信的联系人差点儿相同,因为项目用到了联系人列表索引功能(产品把字母item给去掉了),只是也还是好实现.这里我也来分享分享我的实现,免得以后忘了.那先 ...
- List带索引的常用方法,以及集合的三种遍历
package cn.learn.collection.List; import com.sun.source.tree.NewArrayTree; import java.util.ArrayLis ...
- 【代码笔记】iOS-带索引的tableView
一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController ...
- Python3基础 list(enumerate()) 将一个列表的每一个元素转换成 带索引值的元组
镇场诗: 诚听如来语,顿舍世间名与利.愿做地藏徒,广演是经阎浮提. 愿尽吾所学,成就一良心博客.愿诸后来人,重现智慧清净体.-------------------------------------- ...
- Python3基础 list enumerate 将列表的每个元素转换成 带索引值的元组
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- ngFor 循环带索引
*ngFor="let item of userList,let i = index" 或者 *ngFor="let item of userList index a ...
- C# 数组排序带索引
想到了两种方法来实现,分别利用了List.Sort()和Dictionary.OrderBy()方法,代码如下: , , , , , , , , , }; //List.Sort() List< ...
- 3D游戏引擎设计 实时计算机图形学的应用方法 第2版 pdf 带索引书签目录
3D游戏引擎设计 实时计算机图形学的应用方法 第2版 目录 第1章 概述1.1 图形硬件和游戏发展史1.2 本书版本与软件发展史1.3 章节导读 第2章 图形系统2.1 基础知识2.1.1 坐标系 ...
随机推荐
- An application icon
The application icon is a small image which is usually displayed in the top left corner of the title ...
- ora-4031错误
SQL语句共享的不好,即没有使用绑定变量 来一个SQL语句,在Shared Pool中分配一块内存……再来一个,再分配... 最后共享内存分配完了,有可能都在5k-8K 之间,如果突然又来一个SQL语 ...
- 通过修改css文件来观察openerp表单中的col和colspan
适用版本 openerp 6.1.1 问题的提出 在openerp的表单定义中, 要使用 colspan和col 指你定各个元素的占位, 前者说明了本元素占据其所在容器的列数, 后者说明了本元素作为容 ...
- Lua 字符串库函数总结
字符串库 注:字符串在Lua中是不可变的.不论什么的string操作都不会去改变原有的字符串.都是返回新的字符串 一.一般函数 1. 求长度 s = "Hello LUA "; p ...
- java 中文转拼音之pinyin4j
一.简介 有时候,须要将汉字编程相应的拼音.以方便数据的处理.比方在Android手机应用的开发上.要查询联系人的姓名.通常都是用拼音进行查询的. 比方要查询"曹孟德",就能够输入 ...
- Java下Elasticsearh应用指南
简介 本文针对在Java下操作elasticsearch给出应用示例,主要涉及创建连接,构建索引以及检索数据3个部分. 环境 1)elasticsearch2.4.4, 2)jdk1.8. 客户端连接 ...
- java多线程(四)之同步机制
1.同步的前提 多个线程 多个线程使用的是同一个锁 2.同步的好处 同步的出现解决了多线程的安全问题 3.同步的弊端 当线程较多时, 因为每个线程都会去判断同步上的锁, 这样是很耗费资源的, 会降低程 ...
- no !/ in spec
问题: 在学习hibernate的过程中涉及到hibernate.cfg.xml和hibernate.hbm.xml配置文件的编写,写完之后配置文件出现黄色感叹号,鼠标悬停在感叹号上时显示no !/ ...
- HDUOJ1060Leftmost Digit
Leftmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- HDU----专题训练
Problem A Time Limit : 2000/1000ms (Java/Other) Memory Limit : 20000/10000K (Java/Other) Total Sub ...
