【问题标题】:How can I add a static background behind a UITableView programmatically?如何以编程方式在 UITableView 后面添加静态背景?
【发布时间】:2010-07-26 21:56:37
【问题描述】:

我有一个 TableViewController 并希望有一个静态图片作为背景,它不会滚动。

大家推荐的使用方式

 [UIColor colorWithPatternImage:[UIImage imageNamed:@"backgroundPattern.png"]]

不能正常工作

1.) 移动并 2.) 将背景图案放在每个单元格中

我知道如何在 XIB 文件中执行此操作(即在 TableView 下方添加另一层),但是如何从 TableViewController 以编程方式执行此操作?

【问题讨论】:

    标签: iphone objective-c uitableview uiimageview


    【解决方案1】:
    [myTblViewController.view insertSubview:myImageView belowSubview:myTblViewController.tableView];
    

    应该可以的。

    如果发现tableView不是table view controller主视图的直接子视图,可以试试:

    [[myTblViewController.tableView superview] insertSubview:myImageView belowSubview:myTblViewController.tableView]; //Edited superview should be all lower case
    

    【讨论】:

    • UITableViewController / UIViewController 没有 insertSubview:belowSubview 方法...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-27
    相关资源
    最近更新 更多