UI4_UITableViewEdit
//
// AppDelegate.m
// UI4_UITableViewEdit
//
// Created by zhangxueming on 15/7/13.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "AppDelegate.h"
#import "ViewController.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
ViewController *root = [[ViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:root];
self.window.rootViewController = nav;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible]; return YES;
} //
// ViewController.h
// UI4_UITableViewEdit
//
// Created by zhangxueming on 15/7/13.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import <UIKit/UIKit.h> @interface ViewController : UIViewController<UITableViewDataSource, UITableViewDelegate> @end
//
// ViewController.m
// UI4_UITableViewEdit
//
// Created by zhangxueming on 15/7/13.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "ViewController.h" @interface ViewController ()
{
UITableView *_tableView;
NSMutableArray *_dataList;
} @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
[self.view addSubview:_tableView]; //创建数据源
_dataList = [NSMutableArray array]; NSMutableArray *boys = [NSMutableArray array];
for (int i=0; i<10; i++) {
NSString *name = [NSString stringWithFormat:@"boy%d", i];
[boys addObject:name];
}
[_dataList addObject:boys]; NSMutableArray *grils = [NSMutableArray array];
for (int i=0; i<15; i++) {
NSString *name = [NSString stringWithFormat:@"gril%d", i];
[grils addObject:name];
}
[_dataList addObject:grils]; _tableView.delegate = self;
_tableView.dataSource = self; //编辑状态
self.navigationItem.leftBarButtonItem = self.editButtonItem;
} //设置表示图到编辑状态 - (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
[super setEditing:editing animated:animated];
//让tableView处在编辑状态
[_tableView setEditing:editing animated:YES];
} #pragma mark ---UITableViewDataSource---
//返回分区的行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[_dataList objectAtIndex:section] count];
} //返回分区的个数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return _dataList.count;
} //创建UITableViewCell - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *reuseIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
}
NSArray *array = [_dataList objectAtIndex:indexPath.section];
cell.textLabel.text = [array objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [NSString stringWithFormat:@"age:%d",arc4random()%40+10];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.selectionStyle = UITableViewCellSelectionStyleGray;
return cell;
} - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if (section==0) {
return @"男孩";
}
return @"女孩";
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
UI4_UITableViewEdit的更多相关文章
随机推荐
- tcpdump抓包分析具体解释
說實在的,對於 tcpdump 這個軟體來說,你甚至能够說這個軟體其實就是個駭客軟體, 因為他不但能够分析封包的流向,連封包的內容也能够進行『監聽』, 假设你使用的傳輸資料是明碼的話,不得了,在 ro ...
- leanchat-android
Original: https://github.com/lzwjava/leanchat-android Backup: https://github.com/eltld/leanchat-andr ...
- ccConfig(设置一些底层接口状态:是否支持动作叠加 设置fps更新间隔和位置 是否画边框等。。)
#ifndef __CCCONFIG_H__ #define __CCCONFIG_H__ #include "platform/CCPlatformConfig.h" /** @ ...
- oc-16-set,get方法
S.h #import <Foundation/Foundation.h> /** 解决方案: 1.不用@public修饰 2.我们对象有访问和设置成员变量的两种操作 1>设置值 p ...
- How does a relational database work
http://blog.jobbole.com/100349/ http://coding-geek.com/how-databases-work/
- 在C语言中,double、long、unsigned、int、char类型数据所占字节数
和机器字长及编译器有关系: 所以,int,long int,short int的宽度都可能随编译器而异.但有几条铁定的原则(ANSI/ISO制订的): 1 sizeof(short int)<= ...
- mysql分表研究
分表是分散数据库压力的好方法. 分表,最直白的意思,就是将一个表结构分为多个表,然后,可以再同一个库里,也可以放到不同的库. 当然,首先要知道什么情况下,才需要分表.个人觉得单表记录条数达到百万到千万 ...
- 代码片段------find批量处理
应用案例: 当前目录下有若干目录,有多个目录下有一个名叫build.sh的脚本,但是没有可执行权限,现在要将所有的build.sh假如可执行权限. pengdl@debian:~/work/SDK_3 ...
- Linux中命令链接操作符的十个最佳实例
转载: http://www.linuxeden.com/html/softuse/20140112/147406.html http://www.tecmint.com/chaining-opera ...
- (转)乐观的并发策略——基于CAS的自旋
悲观者与乐观者的做事方式完全不一样,悲观者的人生观是一件事情我必须要百分之百完全控制才会去做,否则就认为这件事情一定会出问题:而乐观者的人生观则相反,凡事不管最终结果如何,他都会先尝试去做,大不了最后 ...