首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NSTableViewCell.ImageView设置位置?

NSTableViewCell.ImageView设置位置?
EN

Stack Overflow用户
提问于 2013-02-23 16:29:31
回答 3查看 115关注 0票数 0

我有一个在计算单元中有一个ImageView的NSTableViewCell。

使用代码控制图像在单元格中的位置需要什么?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2013-02-23 19:00:11

如果您使用的是NSTextFieldCell(ImageAndTextCell)的子类。你可以控制图像的位置

- (NSRect)imageRectForBounds:(NSRect)cellFrame方法。

票数 1
EN

Stack Overflow用户

发布于 2013-02-24 02:11:25

可以创建自定义单元格...

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

    static NSString *CellIdentifier = @"ImageOnRightCell";

    UIImageView *photo;
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]];
        cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;

        photo = [[[UIImageView alloc] initWithFrame:CGRectMake(225.0, 0.0, 80.0, 45.0)]];
        photo.tag = PHOTO_TAG;
        photo.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
        [cell.contentView addSubview:photo];
    } else {
        photo = (UIImageView *)[cell.contentView viewWithTag:PHOTO_TAG];
    }
    return cell;
}

这看起来就像...

或者你可以阅读这个链接...http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/tableview_iphone/TableViewCells/TableViewCells.html

票数 1
EN

Stack Overflow用户

发布于 2013-02-23 18:29:08

创建您自己的自定义TableViewCell并根据需要定位它,而不是默认的tableViewCell。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15038644

复制
相关文章

相似问题

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