分享

IOS上路

 mobilex6 2015-02-26
//
//  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

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多