Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7 lays out accessoryView and accessoryType differently?

Anyone else notice that iOS 7 lays out custom accessoryViews differently than built-in accessoryTypes?

Like this:

enter image description here

The top one is done using:

cell.accessoryView = cell.accessoryButton;

(where accessoryButton is a customized UIButton) while the second one is done using:

cell.accessoryView = nil;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

Same code, same app, same Xcode, but running on iOS 6 instead:

enter image description here

Is this a bug in the SDK? Or something I can control via code?

like image 826
randallmeadows Avatar asked Sep 25 '13 21:09

randallmeadows


1 Answers

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;
}
like image 61
awulf Avatar answered Nov 10 '22 03:11

awulf