views:

11

answers:

1

For some unknown reason I cannot push a view, I will try to explain the best I can but i have alot of complicated views going on, And it would be a nightmare to explain but say I have the following method.

 -(void)showDetailView{ 
DetailViewController *detailView = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
 [self.navigationController pushViewController:detailView animated:YES];
 [detailView release]; 
  }

Which works and would push the detail view onto the stack, this is on my main view and my main thread.

So in the table view i have a cell with a Subview that then takes its view from another view controller. In that view controller I have more subviews, and say when a user clicks a subview a method is called. Which in turn will call this method on the mainView.

So one would believe that then a new view should get pushed. And the code runs, no errors occur but the view is not changed/switched.

I have tried various method of pushing a view inside the view controller that is it called from. and then just calling a method which is directly connected to the navigation controller to push the views.

A few things to add. 1. I have a IBAaction button that pushes a view (that works fine) 2. I assume its because im through so many views but I'm assuming that if you call push view controller it will push whatever view you pass it. 3. I have checked when the method is called from the main view self.navigationcontroller does not = null.

But if the navigation controller is called through the method call it = null.

So is there anyway to restore the null value of a navigation controller?

Im a little confused on why i cant simply call a method to push a view

Thanks

A: 

Its ok I have sorted it now

In terms of how i solved accessing the superior superview to my view is

An ID tag to the views superview which is the cell that my subview is in

id CellController = [self.view.superview.superview nextResponder];
[CellController performSelector:@selector(showDetailView:) withObject:Link];

Then calling a method in my cell which then in turn access its superview

id mainController = [self.view.superview.superview nextResponder];
[mainController performSelector:@selector(showDetailView:) withObject:Link];

Which then the main still retains its navigation controller and then in the show detail method in the main passes the link and pushes the new view.

Basically the total superview of a subview can be no higher then wherever it was created. So the subview in my cell could never access and run anything through my mainView properly, i could stuff but it never performed how it should be. So accessing its highest level superview and then getting that to access its superview as the cell is in my main view then I could run methods correctly.

Hope this makes sense only getting my head around it all.

Thanks to -> http://stackoverflow.com/questions/1034106/how-does-one-access-a-supers-view-controller

For the Id tag bit, not used Id in this way so another things learnt

Scott Roberts

related questions