Push a View Without a Back Button

I think this has come up before but I can’t find the answer. I want to push a view but without the Back Button Title of the previous view (the one that is doing the pushing). Removing the BackButtonTitle text in the Inspector doesn’t remove the title from the view that is pushed (it just shows the previous View’s title as the back button). Can someone point me in the right direction?

Just zero the title for the pushing view :

self.title = ""

Make sure you set the title of your current view in Activate to reinstate it after coming back.

That sort of works, but you are still left with a left arrow in the navigation bar. I want mine to look the same as many of Apple’s own apps, e.g. Calendar, such that when you tap Edit in the toolbar to enter Edit mode, you get a View with a Cancel button on the left and a Done button on the right but no back arrow/name-of-calling-view shown. I can do this with a modal view but I had thought that there was another way to call a view other than PushTo that perhaps didn’t do this?

From that it seems to be a simple boolean property.
http://stackoverflow.com/questions/9499423/ios-how-to-remove-back-button

…not accessible in Xojo though.

I tried to use DeclareMaker but the method crashes :

declare sub setHidesBackButton_ lib "UIKit" selector "setHidesBackButton:animated:" (obj_id as ptr, hidesBackButton as Boolean, animated as Boolean) setHidesBackButton_(self.handle, true, true)

I bet the toolbar handle is needed but Xojo does not expose it.

I know you do not want to simulate the toolbar…

Hah! You know me too well. :slight_smile:

What I’m doing to workaround it is to set the BackButtonTitle of the previous (calling) view to “Cancel”. Then I’m adding a 'Done" button to the RightNavigationToolBar. So I’ve got my “Cancel” and “Done” buttons in edit mode. The only thing is that the Cancel button has a left arrow beside it which takes you back to the previous View. I can live with that for now.

I don’t know if this will help you any, but you can present the new view modally and it won’t have a toolbar at all. You would then have to add your own cancel and done buttons (since it doesn’t seem possible to use the Navigationbar for modal views) but it would eliminate the back arrow problem. To present a view modally:

declare sub presentViewController_ lib UIKitLib selector "presentViewController:animated:completion:" (obj_id as ptr, viewControllerToPresent as ptr, flag as Boolean, completion as ptr) //newView is an instance of iOSView which is the new view you want to present modally, self is the iOSView you want to cover up (what you would normally call self.PushTo() from to display newView PresentViewController_(self.ViewControllerHandle, newView.ViewControllerHandle, True, nil)

To dismiss that view:

declare sub dismissModalViewController lib UIKitLib selector "dismissViewControllerAnimated:completion:" _ (obj_id as ptr, animated as Boolean, completion as ptr) //self is the parent iOSView, not the view you presented modally //you may want to keep a reference to the parent iOSView in the modally presented view so that you can dismiss the modal view from within itself (i.e. by a button) dismissModalViewController(self.ViewControllerHandle, True, Nil)

Thanks Jason. Yes I’ve got a .showModal extension method that I use in my app, but as I have a tabbed interface I didn’t want this particular view to be modal; I wanted it to be part of the current tab. I know, I know, I’m fussy. :slight_smile:

My workaround is OK for now. Thanks though, and please keep up the great work!