views:

688

answers:

2

Hi All!

It's odd, I know, but even if you stated hidesBackButton to YES for the UINavigationItem associated with your view, you will be able to go back just touching the area that was meant to be a back button.

Sharing my solution... (more to come)

A: 

First I thought it was a simulator bug and uploaded to the device. But when I reproduced the same behavior there as well I started to think how to get rid of such behavior (since it was essential for me). Came up to such a solution:

[self.navigationItem setLeftBarButtonItem:[[[UIBarButtonItem alloc] initWithCustomView:[[UIView new] autorelease]] autorelease]];

And to show the back button again you write:

[self.navigationItem setLeftBarButtonItem:nil];

That's simple. Use it as a work-around, guys! Very strange this bug survived even in iPhone OS 3.0...

Aleks N.
Wouldn't it be easy to avoid all those autoreleases? I always alloc and release when unless I can't.
Mk12
True. But I was too lazy that time to create a couple of temp vars. :)
Aleks N.
A: 

i think hiding back bar button also work as

self.navigationItem.hidesBackButton = TRUE;

sandy
Yes, it works. But it also does not prevent you from going back just by touching the place where the back button was meant to be. Please, re-read the post from the very beginning.
Aleks N.
UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] init]; temporaryBarButtonItem.title = @"Back"; self.navigationItem.backBarButtonItem = temporaryBarButtonItem; [temporaryBarButtonItem release];self.navigationItem.hidesBackButton = TRUE; Try this and give your title for that button . In my case it's working. (Not going back)
sandy
Ha-ha. Now see what _I_ am showing in the post. Whose approach is simpler? And what is TRUE doing in Objective C? Just hint. You're doing the same thing I do, but name it differently. Plus have an overhead with setting a value for hidesBackButton while I don't. Plus setting title for the button in your case doesn't have any sense since you will never see it.
Aleks N.
yes what u saying is absolutely right but that depends on requirement ?may be after some particular condition user come back to previous view?this is only restrict to user for a specific condition.in ur case if user can't see that button than how will be come back?
sandy
TRUE and YES are equivalent (basically a macro for the number 1)
Kelso.b