Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
183 views
in Technique[技术] by (71.8m points)

ios - UITableViewCell accessoryView overlap custom button of cell OR how to change accessoryView position?

I am using MSCellAccessory to set custom colour to accessoryView. It worked fine. But when I place button in cell and click on cell, checkmark is visible but it overlaps delete button. Check my snap shot.In this image I set border to accessory view. It appear on delete. So I cannot press delete button.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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;
}

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];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...