What is the meaning of UINavigation's setHidesBackButton? - iphone

- (void)setHidesBackButton:(BOOL)hidesBackButton animated:(BOOL)animated
can anyone tell me the meaning of above statement with an example?

it hides the back button in the left side of your navigation bar. but it does not prevent you from going back
please see
sethidesbackbuttonyes

Description in documentation:
http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UINavigationItem_Class/Reference/UINavigationItem.html#//apple_ref/occ/instm/UINavigationItem/setHidesBackButton:animated:
Example, which hides the back button but does not animate:
[item setHidesBackButton:YES animated:NO];

Related

How do I launch a modal view from a custom UITabBar?

I've built out the raised-center UITabBar from this GitHub location.
My challenge now is that I can't figure out how to create a modal view that will appear when the button is pressed.
Has anyone used the idev-recipes RaisedCenterTabBar with luck? How did you implement the modal sheet that appears there?
Alternatively, is there a different gitHub project that has a working custom tab bar with a modal sheet?
Thank you!
Here was my solution, it was BY FAR the cleanest way I found to do this... I really hope it helps, I spent hours researching the best ways.
I setup a "UITabBarController" delegate that connects directly to my tab interface built out on my storyboard.
** Don't forget to include the "tabBarController" delegate in your header file
** Notice this callback method is NOT the "didSelectViewController" but rather the "shouldSelectViewController". This method handles the request before the tab is selected and that is exactly what you want so you can STOP the request before it ever happens... This way you don't have to save the current index you are on, pass it around and all that nonsense.
Then I am simply checking what tab WILL be selected (based on the view controller's title.
** Also: this is my code, change it as needed for your code. But the principals should remain. My "performSegueWithIdentifier" is actually a manual segue connected to my tab controller that opens in a modal. This code is working brilliant for me.
-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{
if([[viewController title] isEqualToString:#"tellvc"])
{
[self performSegueWithIdentifier:#"shareModelViewController" sender:Nil];
return NO;
}
else
{
return YES;
}
}
I have something similar in a program of mine that I'm working on and would be glad to show you how I do it. I have a couple of viewControllers in a TabBar. I create my Plus button in whichever VC I decide will appear first on the screen in ViewDidLoad.
// Create a plus button that appears on the tabBar
UIImage *plusButton = [UIImage imageNamed:#"plusbutton.png"];
UIView *tabBarView = [[self tabBarController] view];
addButton = [UIButton buttonWithType:UIButtonTypeCustom];
[addButton setFrame:CGRectMake(127.0, 432.0, [plusButton size].width, [plusButton size].height)];
[addButton setBackgroundImage:plusButton forState:UIControlStateNormal];
[tabBarView addSubview:addButton];
[addButton addTarget:self action:#selector(scalePicker:) forControlEvents:UIControlEventTouchUpInside];
I make the button a subView of the tabBarController's view. Later on in the implementation of this VC I have a method called scalePicker: which creates and instance of one of my other VC's and presents it modally. Here is the code for that: (note: this is the method that I set as a target for the plus button in the code above)
-(void) scalePicker:(id)sender
{
// create the view scalePicker, set it's title and place it on the top of the view hierarchy
sp = [[ScalePickerVC alloc] init];
[self presentModalViewController:pickerNavController animated:YES];
}
I hope this helps you,
Good Luck!

iPhone:navigation bar "back" button clickable = NO?

I know that we can hide navigation bar "back" button. But I dont whant to hide it ! Is there any way to make it just not clickable ?
You can not disable the backBarButtonItem. Setting enabled property of backBarButtonItem to NO doesn't actually disables it.
It seems Apple prevented others("us") from disabling backBarButtonItem, even it ignores the target and action set to backBarButtonItem.
try this
self.navigationItem.leftBarButtonItem.enabled=NO;
self.navigationItem.backBarButtonItem.enabled=NO;
Update:
It seems to be Apple doesn't allow the back button to enable / disable. Instead of that we can hide it.
self.navigationItem.hidesBackButton = YES;
self.navigationItem.backBarButtonItem.enabled = NO;
Disable:
self.navigationItem.leftBarButtonItem.enabled = NO;
Enable:
self.navigationItem.backBarButtonItem.enabled = YES;
The default cancel button cannot be disabled as Apple does not allow this feature.
This doesn't work with the default back button.but it's possible to hide the default back button [self.navigationItem setHidesBackButton:YES];
Yes, you can disable that button, just setenabled property of that button to NO.
Should be possible to disable the button:
backButton.enabled = NO;
Apple does not want you to disable it but you can hide it of course.
self.navigationItem.hidesBackButton = YES;
This especially works well if you have a custom UIBarButtonItem as a button.
In stock applications you would notice features that are not applicable are hidden altogether rather than disabled.

Problem when adding Three20 PhotoViewer to my UINavigationViewController

I want a photo viewer in my iphone app and I liked the Three20 photo viewer. I found it somehow hard to integrate it in my own app where I have my typical UINavigationViewController. So far I succeeded in doing the following:
TTURLMap *map = [[[TTURLMap alloc] init] autorelease];
[map from:#"tt://appPhotos" toSharedViewController:[PhotoViewController class]];
[self.navigationController pushViewController:[map objectForURL:#"tt://appPhotos"] animated:YES];
The only problem is that wenn I click back to my original view, its navigation bar keeps the style of the photo viewer (transperant and shows the view under it).
How can I get back my original navigation bar?
My experience: I once used three20's PhotoViewer and every time I went back from the PhotoViewer to my other view. The system status bar remained black and transparent (while it should be with default style). I solved it by manually and programmatically changing the status bar style every time when the back action was triggered.
Yes, this is a bit of an issue for sure. A good solution, as #diwup says, is to implement a manual fix. I tend to subclass TTPhotoViewer when I need it. Not only does it help with this problem but it also makes it much easier to use I find.
If you decide to subclass, then you should use whatever variation of the following you require:
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.tintColor = myTintColor;
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}
However, if you don't want to subclass, you can always put the code into the - [viewWillAppear:] method of any class that comes after the photo viewer.

How to add a HUD? (iOS)

I am trying to have some controls appear when you push a button and have it disappear when you press a different button. Right now the HUD is comprised of an image view, and some custom buttons in a UIView called "credits". I've managed to have it disappear using:
[credits removeFromSuperview];
How do I have it reappear?
If it's just a UIImageView, you should...
[self.view addSubview:credits];
... assuming you've not released it already. On a side note, there is a really good HUD for iOS here: http://github.com/matej/MBProgressHUD
I believe you can just set the view to be hidden
[self.view setHidden:YES];
While it's hidden, you can also update the view and then show again
[self.view setHidden:NO];
You'd better set their hidden property to whether YES or NO
This method will toggle the UIView credits hidden property
- (void) toggleCredits {
[credits setHidden:![credits isHidden]];
}

UINavigationItem setHidesBackButton:YES won't prevent from going back

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)
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...
i think hiding back bar button also work as
self.navigationItem.hidesBackButton = TRUE;