zoukankan      html  css  js  c++  java
  • UITableView 的 delegate2个基本方法

    // 分区中有多少行
    -(NSInteger ) tableView:(UITableView *)tableView
        numberOfRowsInSection:(NSInteger )section
    {
        return [ self.listData count ];
    }
    
    // 添加每一行的信息
    
    - (UITableViewCell *) tableView:(UITableView *)tableView
              cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *tag=@"tag" ;
    //MyClass 是自己实现的UITableViewCell , 包含一个label 和一个按钮
    MyClass *cell=(MyClass *)[tableView dequeueReusableCellWithIdentifier:tag]; if (cell==nil ) { [[NSBundle mainBundle] loadNibNamed:@"Empty" owner:self options:nil]; // cell=[[[ MyClass alloc ] initWithFrame : CGRectZero // reuseIdentifier:tag] autorelease]; cell = cellClass; } NSUInteger row=[indexPath row ]; // cell.textLabel.text =[listData objectAtIndex :row]; CardType *ct = (CardType*)[self.listData objectAtIndex :row]; cell.infoLabel.text = ct.cardType; //给button设置文本的时候,必须同时设置按钮状态,否则无效 [cell.button setTitle: ct.cardID forState:UIControlStateNormal]; return cell; }
  • 相关阅读:
    牛客练习赛9
    Good Bye 2017
    Wannafly挑战赛6
    TOJ1840: Jack Straws 判断两线段相交+并查集
    Codeforces Round #452 (Div. 2)
    TOJ4505: KOSARE
    Codeforces Round #451 (Div. 2)
    牛客练习赛8
    TOJ4168: Same Digits
    TOJ4483: Common Digit Pairs
  • 原文地址:https://www.cnblogs.com/jifsu/p/2151726.html
Copyright © 2011-2022 走看看