I'm looking to have a custom timer object in my navigation bar that displays the time and responds to messages (start
,stop
,etc.). I've successfully added a child view controller to my UINavigationBar using the following code (placed in viewDidLoad
of a UIViewController):
self.timerViewController=[[TimerViewController alloc] init];
self.timerViewController.delegate=self;
[self.timerViewController.view setFrame:CGRectMake(935,
-20,
self.timerViewController.view.frame.size.width,
self.timerViewController.view.frame.size.height)];
[self.navigationController addChildViewController:self.timerViewController];
[self.navigationController.navigationBar addSubview:self.timerViewController.view];
My question is whether this approach could be problematic at all? E.g., is it OK to have a child view controller of a navigationController? (I originally had tried just using the right bar button item with a custom view, but there was a gap between the item and the right side of the screen as described in this question.)