kos
kos

Reputation: 1387

custom UITableViewCell accessory not positioned correctly

I have 2 custom cell in a grouped style table. The one loaded form xib positions accessory view correctly the one created with storyboard does not, although I think it has more to do with dimensions of the cell. See picture:

EDIT: it is irrelevant if accessory is set in the code or if standard accessory is specified through IB

enter image description here

Any ideas why this could be happening and how to fix it?

Upvotes: 1

Views: 745

Answers (1)

kos
kos

Reputation: 1387

In custom cell overwriting layoutSubviews and doing something like this seems to be fixing the issue. However I am still not clear and what the x offset is supposed to be adding 10 gets it close, but what is it actually supposed to be? How is offset is calculated based on height of the cell?

- (void)layoutSubviews {
     [super layoutSubviews];
     self.accessoryView.frame = CGRectMake(self.accessoryView.frame.origin.x **+10**,self.accessoryView.frame.origin.y, self.accessoryView.frame.size.width,self.accessoryView.frame.size.height);
}

Upvotes: 2

Related Questions