//
// SelfTableView.m
// 0719-StoryBoards
//
// Created by vigiles on 13-7-18.
// Copyright (c) 2013年 vigiles. All rights reserved.
//
#import "SelfTableView.h"
/* -------导入数据显示视图-------- */
#import "SelfViewController.h"
@interface SelfTableView ()
@end
@implementation SelfTableView
/* 表格长度。即有多少行单元格 */
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 10;
}
/* 初始化单元格内容 */
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//标示符,要在故事板中和表单控件的单元格关联
NSString * indentifier = @ "Cell" ;
//声明可重用单元格
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:indentifier];
//分配内存,初始化
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indentifier];
}
//文本内容
cell.textLabel.text = [NSString stringWithFormat:@ "%d" , indexPath.row];
return cell;
}
/* 获取点击的单元格 */
-( void )prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath * indexPath = [self.tableView indexPathForCell:sender];
/* ----------操作数据显示视图---------- */
SelfViewController * svc = segue.destinationViewController;
svc.strData = [NSString stringWithFormat:@ "%d" , indexPath.row];
}
@end
|