Search code examples
iosobjective-cuitableviewios5uiappearance

setBackgroundView appearance for UITableView causes endless loop


I faced strange endless loop in some cases using setBackgroundView for UITableView appearance. Here is appearance initialization:

UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @"bg"]];
[[UITableView appearance] setBackgroundView:iv];

I have a controller:

@interface MyController : UITableViewController

that has only init method and viewWill*/viewDid* delegates with simple logging. Nothing else. In such case I'm getting endless messages about layouting subviews:

2013-06-05 21:23:45.054 MyApp[16700:c07] init
2013-06-05 21:23:45.056 MyApp[16700:c07] viewDidLoad
2013-06-05 21:23:45.057 MyApp[16700:c07] viewWillAppear
2013-06-05 21:23:46.059 MyApp[16700:c07] viewWillLayoutSubviews
2013-06-05 21:23:47.061 MyApp[16700:c07] viewDidLayoutSubviews
2013-06-05 21:23:48.064 MyApp[16700:c07] viewWillLayoutSubviews
2013-06-05 21:23:49.066 MyApp[16700:c07] viewDidLayoutSubviews
2013-06-05 21:23:50.067 MyApp[16700:c07] viewWillLayoutSubviews
2013-06-05 21:23:51.069 MyApp[16700:c07] viewDidLayoutSubviews
2013-06-05 21:23:52.070 MyApp[16700:c07] viewWillLayoutSubviews

If I'll switch to:

@interface MyController : UIViewController

everything is going well.

Is this expected behavior (and I didn't understood UIAppearance clearly) or this is broken functionality?

UPD: appearance initialized in AppDelegate.

UPD2: endless loop happens only on table view controllers that are pushed from another one


Solution

  • According to this answer UITableView doesn't support appearance customization using setBackgroundView. So this isn't a bug - it simply unsupported yet.