UITableView Cell ImageView问题

时间:2014-05-24 18:21:08

标签: ios objective-c image uitableview

您好
我的课程中有一个UITableView,当我尝试加载内容时,我会得到一个像这样的屏幕

enter image description here

白框下方无法看到horizo​​dal分隔线,请帮帮我。

我的代码:

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;    //count of section
}


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

    return [names count];    //count number of row from counting array hear cataGorry is An Array
}


- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *MyIdentifier = @"service";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                       reuseIdentifier:MyIdentifier]
        ;
    }

    // Here we use the provided setImageWithURL: method to load the web image
    // Ensure you use a placeholder image otherwise cells will be initialized with no image
    cell.imageView.frame=CGRectMake(5,10,50,60);
    cell.imageView.image=[imaages objectAtIndex:indexPath.row];
    cell.textLabel.text = [names objectAtIndex:indexPath.row];
    cell.backgroundColor=[UIColor clearColor];
    return cell;
}

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

    return 80;

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

1 个答案:

答案 0 :(得分:5)

在你的视图中写下加载

在iOS 7及更高版本中,单元格分隔符不会一直延伸到表格视图的边缘。此属性设置表格中所有单元格的默认插入内容,就像rowHeight设置单元格的默认高度一样。它还用于管理在普通样式表底部绘制的“额外”分隔符。

// Do any additional setup after loading the view.
if ([_tableView respondsToSelector:@selector(setSeparatorInset:)]) {
    [_tableView setSeparatorInset:UIEdgeInsetsZero];
}