-->

Detect and handle, or override, clicks on a naviga

2019-08-23 11:18发布

问题:

I have an app where I've pushed two items onto the navigation bar. The top item, which ends up as a 'back' button, should have the function to jump all the way back to the start page, which is a list of web news. The other one simply displays a logo. The boss wants a navigation bar look and feel but with a simple function, so the user can click around the news site, but always be able to jump to the news list page with just the one click.

Is the only option to create a fixed navbar with two items in IB, so that I can connect an outlet to the clickable item - or is there some way to intercept clicks to the navbar to make a requestURL? touchesBegan or touchUpInside would be fine, but I've found no way of implementing that so far.

It's okay if the whole navbar is clickable, I just need some hint how to make it happen. Add a transparent UIlabel on top and detect clicks for that, maybe?

A bonus would be to hide the item in the 'back' position without popping it from the stack.

回答1:

Answer not needed anymore. I think it's just setting backBarButton to your own I've found no way to just change the title and target. Closing this. My solution back then was to make it a Toolbar, worked okay.