zoukankan      html  css  js  c++  java
  • UITableView

        // 初始化VIEW

        UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];

        tableView.dataSource = self;

        tableView.delegate = self;

        [self.view addSubview:tableView];

    // ****************实现委托   <UITableViewDataSource, UITableViewDelegate>

    // 总数

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

    {

        return _dataArra.count;

    }

    // 获取元素cell view

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

    {

        int indexPosition = indexPath.row;

        

        Person *person = [_dataArra objectAtIndex:indexPosition];

        

        //

        static NSString *identifyString = @"mytableview";

        

        UITableViewCell *cellView = [tableView dequeueReusableCellWithIdentifier:identifyString];

        

        if(!cellView)

        {

            cellView = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifyString];

        }

        cellView.textLabel.text = person.name;

        cellView.detailTextLabel.text = person.telPhone;

        

        return cellView;

    }

    // 行高

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

    {

        return 50;

    }

    // 点击事件响应

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

    {

        int index = indexPath.row;

        Person *person = [_dataArra objectAtIndex:index];

        

        NSLog(@"person name is : %@", person.name);

    }

  • 相关阅读:
    .net中实现运行时从字符串动态创建对象
    C# 用 VB.net 函數庫 實現全角與半角轉換
    實現.net 加載插件方式
    VS2008下載
    Lotus Notes Send EMail from VB or VBA
    用C#写vs插件中的一些Tip
    SQL2005中异常处理消息框可直接使用
    C#路径/文件/目录/I/O常见操作汇总
    利用.net反射动态调用指定程序集的中的方法
    说说今年的计划
  • 原文地址:https://www.cnblogs.com/xiangjune/p/4944798.html
Copyright © 2011-2022 走看看