您的位置:首页 > 产品设计 > UI/UE

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: