How to Notify RootViewController of View Changes - objective-c

I have added a UIButton to a toolbar that is only accessible via the RootViewController (which has a navigation bar and toolbar) of my app. When navigating to another view, I hide the UIButton, but when I go back to the initial screen (a map view) the UIButton remains hidden and I must unhide it. Since it is the RootViewController I am doing this in, viewWillAppear is not called, so I cannot use that method.
I am wondering if there is any way the RootViewController knows when a view is being popped off the navigationController stack, if so, how would you suggest I check for this? Is there any way you would recommend implementing this?
Thanks in advance!

if your app using UINavigationController for navigation then viewWillAppear will obviously called

Related

Reset the former ViewController presented

i've embed my first ViewController in an navigation controller. This auto generate an back button to all the ViewControllers.
The problem is that when i save a video into my core data it automatic go to a new ViewController, but then i'm able to go back to the ViewController where i added the video. Is there a way to like delete/reset the former ViewController that has presented and therefor control how far you can go back by clicking the back button?
Or what would be the best solution?
It's hard to offer advice without seeing your exact use case, but it sounds as though instead of pushing a viewController onto a navigation stack, you might want to do something like present a modal viewController.
Instead of doing pushViewController:animated, try [self presentViewController:newViewController animated:YES completion:nil]. If you're presenting your viewController via a segue in Interface Builder, change the segue type to 'modal'.
You'll also then need to add a button to dismiss your viewController - you can use the [self dismissViewController:animated:completion] method.

Add a UINavigationBar and UIToolbar to modal UITableViewController

I'm creating an app that has a similar layout as the Apple Contacts app. I have created a UITableViewController and embedded it in a UINavigationController using a Storyboard. I then have an add button that opens a UITableViewController in a modal view. I have added a top bar to this view using the storyboard and it works pretty good. The problem is that it scrolls away when you scroll in the table. It should stick to the top.
Do I need to embed this modal UITableViewController in a UINavigationController as well to get the "sticky top bar"?
What's the preferred way of doing this? Just embed using the storyboard or just create one "on the fly" in the prepareForSegue method?
EDIT
I ended up just embedding the modal UITableViewControllers in UINavigationControllers using Storyboard.
Yes, you do need a UINavigationController that contains the UITableViewController to get what you aim for.
Personally, I would prefer creating it "on the fly" as you call it. But that is a matter of taste.
The way to do it in the storyboard is to have your modal view controller be a UIViewController rather than a UITableViewController. Add a view controller, then drag in a tool bar, and position it at the top. Then add a table view to take up the rest of the space below the tool bar. This will work correctly without scrolling with the table view.

Mixing UITableViewController and UITabBarController

I want to combine UITableViewController and UITabBarController:
1) UITableViewController with navigation is shown
2) UITabBarController is pushed
([self.navigationController pushViewController:nextController animated:YES];),
the tabbar is shown, navigationItem is invisible, but the navigationBar stays.
Is this possible? Is there an example?
Correct me if I'm wrong, but it sounds like you have a UINavigationController with a UITableViewController pushed onto it and you would like to push a UITabBarController on to the navigation stack as well. If that is the case, then you may want to read Apple's View Controller Programming Guide for iOS where is states the following:
"Although a navigation controller can be embedded inside a tab, the reverse is not true. Presenting a tab bar interface from within a navigation interface is potentially confusing for users."
Having written that, there is a way to do it, but you must use a custom UIViewController instead of a UITabBarController. This is discussed in detail here

popViewController problem in tableViewController

In my app delegate I have a navigationController property.
In my first view I have some buttons and tapping them will make another view appear when it is pushed on navController.
In this new view there is another button to open a UITableViewController by pushing it on the navController.
The problem is in the last view, UITableViewController, in fact in viewDidLoad, if I have no data, I try to pop it off the navigationController but my app crashes.
However, if I connect the pop to a button it works great.
I reference my app delegate instance in order to popViewControllerAnimated:, so what is the problem?
I'm not sure what's wrong with the code, can you post your viewDidLoad method?
Also, is it possible to check whether your table will have data BEFORE you push the tableView onto the nav stack? That would be a much cleaner UI, rather than showing and then immediately popping a view. If there is no data, disable the button that launches the table view.

Keyboard handling on a UIModalPresentationFormSheet presented sheet

I have a UIViewController that is presented with UIModalPresentationFormSheet. So when the keyboard is visible it stays visible until the view controller gets dismissed.
In that UIViewController I have a navigation controller. So in every UIViewController pushed to that navigation controller I have to check these things:
when the keyboard shows/hides I have to adjust the contentInset
when view appears I have to check if the keyboard is visible or not (the navigation controller remembers that with the notification) and adjust the contentInset. I push UITableViewControllers there, so I don't get viewDidAppear and co. So I have to do all this with the UINavigationControllerDelegate methods?
on every rotation I have to do adjust the contentInset
Otherwise the keyboard may cover some content.
Is that the correct handling? Isn't there any easier solution for this problem? Because this is kind a messy!
I didn't found a better solution, so i did it this way.