Objective c NSTableViewCell.ImageView设置位置?

Objective c NSTableViewCell.ImageView设置位置?,objective-c,xcode,cocoa,Objective C,Xcode,Cocoa,我有一个NSTableViewCell,它在单元格中有一个ImageView 使用代码控制图像在单元格中的位置需要什么?创建自己的自定义TableViewCell,而不是默认的TableViewCell,并根据需要对其进行定位。如果您使用的是NSTextFieldCell()的子类。您可以在 -(NSRect)imageRectForBounds:(NSRect)cellFrame方法。您可以创建自定义单元格 - (UITableViewCell *)tableView:(UITableView

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


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

创建自己的自定义TableViewCell,而不是默认的TableViewCell,并根据需要对其进行定位。

如果您使用的是
NSTextFieldCell
()的子类。您可以在

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

您可以创建自定义单元格

- (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;
}
这看起来像。。。。 或者你可以阅读这个链接。。。。

您正在使用NSTextFieldCell的子类吗?