【问题标题】:insert image on table view?在表格视图上插入图像?
【发布时间】:2011-03-11 13:15:38
【问题描述】:

如何在简单的 tableview 上插入图像?我有一个表格视图,但如果我这样插入:

self.view.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"image.png"]];

我在图像开头的每个单元格中都看到了图像,这太可怕了!

感谢关注!

【问题讨论】:

    标签: iphone objective-c ios uitableview uiimage


    【解决方案1】:

    要设置TableViewController 的背景,您可以在viewDidLoad 方法中使用此代码:

    self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]];
    self.tableView.backgroundColor = [UIColor clearColor];
    

    如果您尝试在单元格中设置图像,您可以在 tableView:cellForRowAtIndexPath: 方法中使用此代码

    cell.imageView.image = [UIImage imageNamed:@"image.png"];
    

    【讨论】:

    • 谢谢!!!这是解决方案:self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]]; self.tableView.backgroundColor = [UIColor clearColor];
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-08
    • 2016-01-24
    • 2013-07-28
    相关资源
    最近更新 更多