Amogh Talpallikar
Amogh Talpallikar

Reputation: 12184

How to access Navigation Bar from a View Controller of a subview ?

I have a View Controller where I select some data into an array and then optionally on clicking of a button I show that data in a TableView added as a subview to previous view with a flip animation.

Now I have the facility to delete data from array I have picked from first view and passed to this one.

Now I have a condition that there is a button on the righthand side on the navigationBar on whose controller the previous view was pushed.

Now that button needs to be disabled until there r atleast X number of elements in the array. so while I am adding data In my previous view, I keep check on the array and as soon it crosses the required count , I enable the button.

Now in the other view which is a TableView which has been brought in with animation, Whenever I delete data I need to disable the button again when it goes below the number X.

How can I access the navigationBar's button in this subview's controller ? shall I set the first view Controller as delegate in the next one ?

Upvotes: 1

Views: 3480

Answers (3)

Vignesh
Vignesh

Reputation: 10251

My opinion is you can create a uinavigationController object in your subview and assign it from your parent view(Where you have the navigation controller object). You can then access the navigation controller in the subview.

Upvotes: 0

fibnochi
fibnochi

Reputation: 1113

try using superView proprty or loop through all the pushed ViewController and check if it is previous VC. Then make the button enabled or disabled

Upvotes: 0

Kyr Dunenkoff
Kyr Dunenkoff

Reputation: 8090

If your viewController is inside UINavigationViewController, you can set navigationBar buttons with self.navigationItem.leftBarButtonItem and self.navigationItem.rightBarButtonItem.

Upvotes: 1

Related Questions