UITableViewCell annexView重叠单元格的自定义按钮,或者如何更改AccessoriesView的位置? [英] UITableViewCell accessoryView overlap custom button of cell OR how to change accessoryView position?

查看:71
本文介绍了UITableViewCell annexView重叠单元格的自定义按钮,或者如何更改AccessoriesView的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

那么如何在UITableViewCell中更改单元附件的位置或在删除按钮下方设置附件的视图.

So how to change cell accessoryView position in UITableViewCell or set accessoryView below delete button.

推荐答案

如果要对UITableViewCell进行子类化,则可以在layoutSubviews中对其进行调整

If you are sub-classing the UITableViewCell you can adjust it in layoutSubviews

- (void)layoutSubviews {
    [super layoutSubviews];

    CGRect accessoryViewFrame = self.accessoryView.frame;
    accessoryViewFrame.origin.x = CGRectGetWidth(self.bounds) - CGRectGetWidth(accessoryViewFrame);
    self.accessoryView.frame = accessoryViewFrame;
}

其他......
添加一个子视图,而不是annexView

OTHERWISE......
Add a subview instead of 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];

这篇关于UITableViewCell annexView重叠单元格的自定义按钮,或者如何更改AccessoriesView的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆