iOS UI 07 uitableview
2015-12-13 16:02
405 查看
//
// RootViewController.m
// ui - 07
//
// Created by dllo on 15/11/18.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import "RootViewController.h"
@interface
RootViewController () <UITableViewDataSource,
UITableViewDelegate>
@end
@implementation RootViewController
- (void)viewDidLoad {
[super
viewDidLoad];
self.view.backgroundColor = [UIColor
whiteColor];
UITableView *table = [[UITableView
alloc]initWithFrame:CGRectMake(0, 0,
self.view.frame.size.width,
self.view.frame.size.height)
style:UITableViewStylePlain];
table.delegate =
self;
table.dataSource =
self;
[self.view
addSubview:table];
[table release];
// Do any additional setup after loading the view.
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
static NSString *cellstr =
@"cell";
UITableViewCell *Cell = [tableView
dequeueReusableCellWithIdentifier:cellstr];
if (nil == Cell) {
Cell = [[[UITableViewCell
alloc]initWithStyle:
UITableViewCellStyleValue1 reuseIdentifier:cellstr]
autorelease];
// Cell.textLabel.text = @"18733324546";
Cell.imageView.image =[UIImage
imageNamed:@"1.png"];
}
if (1 == indexPath.section && 0 == indexPath.row) {
Cell.textLabel.text =
@"大哥";
Cell.detailTextLabel.text =
@"138847";
}
return Cell;
}
- (void)didReceiveMemoryWarning {
[super
didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 5;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 3;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if (section == 0) {
return @"A";
}
if (section == 1) {
return @"B";
}
return @"c";
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
// RootViewController.m
// ui - 07
//
// Created by dllo on 15/11/18.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import "RootViewController.h"
@interface
RootViewController () <UITableViewDataSource,
UITableViewDelegate>
@end
@implementation RootViewController
- (void)viewDidLoad {
[super
viewDidLoad];
self.view.backgroundColor = [UIColor
whiteColor];
UITableView *table = [[UITableView
alloc]initWithFrame:CGRectMake(0, 0,
self.view.frame.size.width,
self.view.frame.size.height)
style:UITableViewStylePlain];
table.delegate =
self;
table.dataSource =
self;
[self.view
addSubview:table];
[table release];
// Do any additional setup after loading the view.
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
static NSString *cellstr =
@"cell";
UITableViewCell *Cell = [tableView
dequeueReusableCellWithIdentifier:cellstr];
if (nil == Cell) {
Cell = [[[UITableViewCell
alloc]initWithStyle:
UITableViewCellStyleValue1 reuseIdentifier:cellstr]
autorelease];
// Cell.textLabel.text = @"18733324546";
Cell.imageView.image =[UIImage
imageNamed:@"1.png"];
}
if (1 == indexPath.section && 0 == indexPath.row) {
Cell.textLabel.text =
@"大哥";
Cell.detailTextLabel.text =
@"138847";
}
return Cell;
}
- (void)didReceiveMemoryWarning {
[super
didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 5;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 3;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if (section == 0) {
return @"A";
}
if (section == 1) {
return @"B";
}
return @"c";
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
相关文章推荐
- iOS UI 05 传值
- iOS UI 05 传值
- iOS UI 04 轨道和动画
- iOS UI 04 轨道和动画
- iOS UI 03 协议代理
- iOS UI 03 协议代理
- iOS UI 03 事件和手势
- iOS UI 03 事件和手势
- UIButton中
- iOS UI 02 UIimageview 和模态切换
- iOS UI 02 UIimageview 和模态切换
- go build命令
- iOS UI 01 课堂笔记 -设计模式
- iOS UI 01 课堂笔记 -设计模式
- IOS UI 01 课堂笔记 -label
- IOS UI 01 课堂笔记 -label
- 使用yuicompressor-maven-plugin插件压缩JS和CSS静态资源
- UILabel: 如何可以更改除底部外的所有边框?
- Android 异步更新UI----handler+thread
- WebKit之CSSValue的继承关系