I'm attempting to use a UIRefreshControl
inside my UITableViewController
which itself is inside a UINavigationController
, which has its hidesNavigationBar
property set to NO
(so the navigation bar is visible).
The UIRefreshControl
works, but is obscured by the UINavigationBar
. I'm surprised I can't find anyone else who has run into this problem.
Possible relevant points:
rootViewController
of my UIWindow
to be my UINavigationController
.UINavigationController
by setting the viewControllers
property of the UINavigationController
.UITableViewController
subclass is instantiated with a nib.UIRefreshControl
in the viewDidLoad
method of my UITableViewController
subclass. I set the refreshControl
property of the UITableViewController
subclass in this method.UIRefreshControl
works perfectly fine, and I can see a portion of it, but it is obscured by my UINavigationBar
. It looks completely normal if I set hidesNavigationBar
to YES
(but I don't want to hide it).The code used to create and position my UIRefreshControl
is:
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self
action:@selector(toggleRefresh:)
forControlEvents:UIControlEventValueChanged];
self.refreshControl = refreshControl;
This code snippet is in the viewDidLoad
method of my UITableViewController
subclass, which is a child view controller of a UINavigationViewController
.
For those targeting iOS 7, there seems to be a new issue present where the UIRefreshControl
is drawn behind the UITableView
's backgroundView
. I experienced this both when initializing the UIRefreshControl
programatically and from a storyboard. A simple workaround is to update the zPosition
of the UIRefreshControl
in viewDidLoad
of your UITableViewController
:
self.refreshControl.layer.zPosition = self.tableView.backgroundView.layer.zPosition + 1;