简易表视图

来源:互联网 发布:阿里云服务器使用手册 编辑:程序博客网 时间:2024/06/02 06:26

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section   
{
    return [self.listData count];
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSArray *SimpleTableIdentifier = @"水果";
   
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault   

reuseIdentifier:SimpleTableIdentifier] autorelease];
       
    }
    NSUInteger row = [indexPath row];
/*
NSUInteger是无符号的整型, NSInteger是有符号的整型
索引值要用NSUInteger
例如:NSUInteger row=[indexPath row]
因为索引值永远不小于0,是非负数,所以用NSUInteger来代表更加准确。
*/
 
    cell.textLabel.text = [listData objectAtIndex:row];
    return cell;
}