views:

50

answers:

1

Hi, I have a Tableview on AppDelegate That calls a SecondView (dvController) when DidSelectRowAtIndexPath using:

[self.window addSubview:[dvController view]];

On SecondView I defined a button linked to IBAction that should go back to previous view. It works great but when row selected but, How could then go back to previous view if main one is AppDelegate?

self.window addSubview:[?? view]];

Should be basic concept but I am quite new and unable to get the solution. Thanx :)

+1  A: 

addSubview should be called when you want to add subview to the end of current view's subviews list. If you want get back to previous view, use [self.view removeFromSuperview]; instead. (Syntax may be wrong - no Mac somewhere near)

kpower
In this case, `[[dvController view] removeFromSuperview]`. The key point here is that the inverse of `addView:` is not `addView:`; the inverse of adding a view is removing that view, which you do, as you said, by telling it to remove itself.
Peter Hosey
Hey guys, I am really thankful!! It works!! Hope can help soon answering your posts. Thanks again and have a nice day
Ruthy