Roman Shkarin
Roman Shkarin

Reputation: 177

How to get UITableViewStyle inside UITableViewCell

I had tried check inside cell backgroundView, but for both styles (UITableViewStylePlain, UITableViewStyleGrouped) were equal to NOT nil. There is whether any way to get UITableViewStyle from inside UITableViewCell?

SOLVED: I just added to cell constructor a variable of type UITableViewStyle and set it when created

Upvotes: 0

Views: 1191

Answers (1)

Anomie
Anomie

Reputation: 94834

Ideally, your cell shouldn't care what the style is.

But if you must know, your best bet is to do something like this:

UIView *tv = self;
while (tv && ![tv isKindOfClass:[UITableView class]]) tv = tv.superview;
UITableViewStyle style = [(UITableView *)tv style];

Upvotes: 1

Related Questions