0

我有一个 NSTableViewCell,它在单元格中有一个 ImageView。

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

4

3 回答 3

1

如果您使用的是NSTextFieldCellImageAndTextCell)的子类。
- (NSRect)imageRectForBounds:(NSRect)cellFrame您可以在方法中控制图像的位置。

于 2013-02-23T11:00:10.567 回答
1

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

- (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

于 2013-02-23T18:11:25.103 回答
0

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

于 2013-02-23T10:29:07.983 回答