iphone - UITabBarController 更多NavigationController 表格单元格背景图像

标签 iphone uitableview uitabbarcontroller background-image

哇,那真是一口。 :)

我们已经在customizing the more menu (table view) in a tab bar上看到了一个很好的帖子。 .

对于我们的下一个技巧……如何向表格单元格添加背景图像?

我认为我可以在“更多 TableView ”的数据源类中重写tableView:cellForRowAtIndexPath:(有关方法,请参阅前面的链接)。唉,它只更改了每个单元格左侧和右侧图像和附件 View 下的背景。

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    // Let the original Data Source get a hold of the cell first.
    UITableViewCell *cell = [originalDataSource tableView:tableView cellForRowAtIndexPath:indexPath];

    // If we override the textColor, that works fine. (Commented out for now.)
    //cell.textLabel.textColor = [UIColor whiteColor];

    // If we override the background view … that doesn't work so well.
    cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellBackground.png"]];

    return cell;
}

我知道,imageNamed:是邪恶的,也许我应该创建一个背景图像并在整个过程中重复使用它(而不是分配多个UIImageView对象)。除了这些东西,还有什么想法吗? (我也尝试调整 textLabel 的背景颜色,但无济于事......除非我在那里做错了什么。)

最佳答案

Here就是答案...

添加代码

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

MoreTableViewDataSource方法

关于iphone - UITabBarController 更多NavigationController 表格单元格背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1556430/

相关文章:

ios - 从 NSDictionary 填充 tableview

ios - UITabBarController didSelect 和 shouldSelect 在呈现和关闭 webView 后不再调用

ios - 将新选项卡添加到选项卡栏 Controller

iphone - 使用个人存储库向 Cydia 提交付费应用程序 - 可能吗?

iphone - 使用自定义 URL 方案从日历笔记启动我的应用程序

iphone - UITextView 或 UILabel 的边框可以在 Storyboard 中设置吗?

ios - UITabBarController 应用程序在每个选项卡中都有 UIWebViews

iphone - MFMailComposeViewController 在 iOS5 中 dismissModalViewControllerAnimated 时崩溃

ios - 实时更新 UITableViewCell 中的 UILabel

ios - 如何在 Objective C 中访问父对象