Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableViewCell accessoryView单元格重叠自定义按钮或如何更改accessoryView位置?_Ios_Objective C_Iphone_Ipad - Fatal编程技术网

Ios UITableViewCell accessoryView单元格重叠自定义按钮或如何更改accessoryView位置?

Ios UITableViewCell accessoryView单元格重叠自定义按钮或如何更改accessoryView位置?,ios,objective-c,iphone,ipad,Ios,Objective C,Iphone,Ipad,我正在使用将自定义颜色设置为accessoryView。它工作得很好。但当我在单元格中放置按钮并单击单元格时,复选标记是可见的,但它与删除按钮重叠。检查我的快照 因此,如何在UITableViewCell中更改单元格accessoryView位置或在delete按钮下方设置accessoryView。如果要对UITableViewCell进行子分类,可以在LayoutSubView中对其进行调整 - (void)layoutSubviews { [super layoutSubviews

我正在使用将自定义颜色设置为accessoryView。它工作得很好。但当我在单元格中放置按钮并单击单元格时,复选标记是可见的,但它与删除按钮重叠。检查我的快照


因此,如何在UITableViewCell中更改单元格accessoryView位置或在delete按钮下方设置accessoryView。

如果要对UITableViewCell进行子分类,可以在LayoutSubView中对其进行调整

- (void)layoutSubviews {
    [super layoutSubviews];

    CGRect accessoryViewFrame = self.accessoryView.frame;
    accessoryViewFrame.origin.x = CGRectGetWidth(self.bounds) - CGRectGetWidth(accessoryViewFrame);
    self.accessoryView.frame = accessoryViewFrame;
}
否则……
添加子视图而不是accessoryView

UIButton *indicatorBtn = [UIButton  buttonWithType:UIButtonTypeCustom];
indicatorBtn.frame = CGRectMake(cell.contentView.frame.size.width-55, 2, 50, 50);
[indicatorBtn setBackgroundImage:[UIImage imageNamed:@"right_indicator.png"] 
                        forState:UIControlStateNormal];
indicatorBtn.backgroundColor = [UIColor clearColor];
//indicatorBtn.alpha = 0.5;
indicatorBtn.tag = indexPath.row;
[indicatorBtn addTarget:self action:@selector(method:) 
       forControlEvents:UIControlEventTouchUpInside];

[cell.contentView addSubview:indicatorBtn];

我通过为tick添加UIImageView解决了这个问题。放在删除按钮旁边,它对我有效。我没有使用桌上电池配件。请检查下面的代码

- (UITableViewCell *)reuseTableViewCellWithIdentifier:(NSString *)identifier
{
CGRect cellRectangle = CGRectMake(0, 0, CGRectGetWidth(tableViewSavedSearch.frame), tableViewSavedSearch.rowHeight);
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
cell.frame = cellRectangle;
CGFloat imageWidth = 30;

//Name
UILabel *lblName = [DesignModel createPaddingLabel:CGRectMake(0, 0, CGRectGetWidth(cellRectangle) - (imageWidth * 2), tableViewSavedSearch.rowHeight) labelTag:TAG_SAVED_SEARCH_NAME textColor:COLOUR_BLUE_DARK textAlignment:NSTextAlignmentLeft textFont:[UIFont fontWithName:FONT_CENTURY_GOTHIC size:14] padding:UIEdgeInsetsMake(0, 5, 0, 5)];
[cell.contentView addSubview:lblName];

//Delete button
UIButton *button = [DesignModel createImageButton:CGRectMake(CGRectGetMaxX(lblName.frame), 0, imageWidth, tableViewSavedSearch.rowHeight) image:imageDelete tag:TAG_SAVED_SEARCH_DALETE];
[button addTarget:self action:@selector(btnSaveAndSearch_DeleteAction:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:button];

//TICK
UIImageView *imageView = [DesignModel createImageView:CGRectMake(CGRectGetMaxX(button.frame), 0, imageWidth, tableViewSavedSearch.rowHeight) image:imageTick tag:TAG_SAVED_SEARCH_TICK contentMode:UIViewContentModeCenter];
[cell.contentView addSubview:imageView];

return cell;
}

创建自己的UITableViewCell子类