Current UIView

Discussion in 'iOS Programming' started by iphonejeffneil, Mar 5, 2010.

  1. iphonejeffneil macrumors newbie

    Mar 5, 2010
    I am programming an app that is going to contain multiple views that are interlinked. It has a menu bar that allows you to move from view to view. I am stuck on the view switching because I am unaware of a call that will return my current view.

    Basically in order to switch views I have to remove my current view and add my new subview but in order to remove my current view I need my app to know what that there any call that returns my current view so I can remove that view from superview and place my new view etc.

    Hope that makes sense.

  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    Why are you not just pushing a view controller into the navigation controller stack?

    UINavigationController Documentation...
  3. iphonejeffneil thread starter macrumors newbie

    Mar 5, 2010
    Thanks that is exactly what I need. My one question is do I have to use a "NavigationBar" item with UIBarButtons? The way that I have it set up now is basically a static image along the top of the app with UIButtons so that it looks similar to a navigation bar but it is customized and significantly wider, is this possible or will I have to change to a navigation bar?
  4. iphonejeffneil thread starter macrumors newbie

    Mar 5, 2010
    UIViewController Problems

    I posted earlier but am running into similar problems again. Basically the way that my app is setup there is a top bar that is basically just a static image that has UIButtons placed on top of it. That is the Main View Controller and is persistent no matter what view is shown beneath it. I can't use a navigation controller because it is not possible to change the height and I need the bar to be significantly larger than a navbar. However my bar is functioning in much the same way. There is a "Home" Button, a "Back" Button and several destination buttons.

    I understand how to switch views from say the home screen. My confusion comes with the back button. In order to press back the app is going to need to know what view is currently being displayed so that it can be removed from view and a new subview can be added. Ideally I would use the UINavigationController so that I can push and pop views which is really what I want to do here, however that is not possible because of the visual problem.

    Does anybody know of a method that returns the current displayed view so I could do something like the following

    [[B]currentview[/B].view removeFromSuperView];
    [self.view insertSubview:experienceViewController.view atIndex:0]
  5. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    You can use a nav controller with a hidden navbar. I highly recommend that you do things that way. You may need to set up a delegate for the nav-controller to get notified when things change so you can update the appearance of your topBar.

Share This Page