首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >HowTo?UISplitViewController TableCell图像

HowTo?UISplitViewController TableCell图像
EN

Stack Overflow用户
提问于 2011-10-28 12:46:27
回答 1查看 225关注 0票数 1

我想知道是否可以将某种图标/图像分配给iPad应用程序中UISplitViewController左侧的导航表格单元格。

例如,第1行旁边的图像...

http://www.cre8ive.kr/blog/wp-content/uploads/SplitViewTest_03.png

我正在尝试通过编辑

代码语言:javascript
复制
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; 

方法。

这是我得到的

代码语言:javascript
复制
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];    
    }
    cell.textLabel.text = [NSString stringWithFormat:@"%i", indexPath.row +1];  
    //Let the magic happen here :D
    UIImage *image = [UIImage imageNamed:@"deviantart_dark.png"];
    //Nothing changes :(
    [[cell imageView] setImage:image];
    return cell;
}

有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-10-28 13:05:05

你可以使用下面的代码,

代码语言:javascript
复制
cell.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage:imageNamed:@"deviantart_dark.png"]];
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7925243

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档