【问题标题】:UITableView Cell ImageView issue [duplicate]UITableView Cell ImageView问题[重复]
【发布时间】:2014-05-24 18:21:07
【问题描述】:


我的课堂上有一个UITableView,当我尝试加载内容时,我得到了这样的屏幕

在白框下方看不到水平分隔线,请帮帮我。

我的代码:

    - (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{
}

【问题讨论】:

    标签: ios objective-c image uitableview


    【解决方案1】:

    写在你的视图中确实加载了

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

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

    【讨论】:

    • 不...仍然无法正常工作
    • _tabview 是您的表格视图对象,在您的情况下可能是 self.tableView。试试看
    • [tableView setSeparatorInset:UIEdgeInsetsZero];这是工作
    • 是的,它是一样的,但是如果你在 ios 6.0 中运行它会崩溃,因为 setSeparatorInset 方法在 7.0 之后可用,这就是为什么我首先检查表视图是否响应 setSeparatorInset。跨度>
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-07
    • 1970-01-01
    • 2019-07-07
    • 2011-07-23
    相关资源
    最近更新 更多