UITabBarController hides but white space remaining - iphone

I have UITabBarController in my app.
In a particular view I want to hide the tabbar and display the content up to the below line.
For that I used the code in the view
-(void)viewWillappear{
[self.tabBarController.tabBar setHidden:YES];
}

It depends what your content is, but if it's inside a container, like a UIView, you can change the autoResizingMask to be
myView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
and it should do the right thing.

Related

How to make a view have a semi-transparent border and show the view below

Probably a bit of a newbie question, but .... I am writing an iPhone app which uses UITabBarController.
In Interface Builder I've setup the tab bar in MainWindow.xib. I have 4 tabs, and each one is set to load the xib for the appropriate UIViewController subclass. I have created the views in the xib files for each UIViewController subclass in Interface Builder.
All is working well in that I can tap each tab and it shows the view for the correct UIViewController
But what I really want is for the view for one of the UIViewController subclasses to have a semi-transparent border of approx 30px on all 4 edges, so that it shows the edges of the view behind, kind of greyed out.
IE. the first tab is the main application, and that takes up the whole screen (minus the status and tab bar areas).Tab 2 is to save, and I want it to look like a small modal window over the top of the main app.
(If I were doing this as a html web app, the terminology and technology I'd be using would be a jQuery overlay)
Does this make sense?
I've tried playing with presentModalViewController but this makes it worse in that it takes up the entire screen including the status and tab bar areas.
Any help or pointers very much appreciated
Cheers
Nathan
Your UIViewController cannot be transparent to the view below it because the iphone may unload the view below it that is not currently being shown (to save memory).
The best solution I have used is to take a picture of the current view before you push your new view controller and then use that as the background image (fake the transparency). Here's how I implemented this:
NewViewController *newView = [[NewViewController alloc] init];
shareVC.imageBackground = [Utilities getScreenshot:self.view];
[self presentModalViewController:newView animated:YES];
[newView release];
then on your newViewController do this (on viewDidLoad, viewWillAppear, etc):
[imageView setImage:imageBackground];
and here's the screenshot function
+(UIImage *)getScreenshot:(UIView *)_view {
//take a screenshow of the parent view so we can add it as a background to the modal view
if ([[UIScreen mainScreen] respondsToSelector:#selector(scale)])
UIGraphicsBeginImageContextWithOptions(_view.window.bounds.size, NO, [UIScreen mainScreen].scale);
else
UIGraphicsBeginImageContext(_view.window.bounds.size);
[_view.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
You then need to setup your new view with a UIImageView as the background and pick the right Alpha value for that imageView to make it appear like it's transparent.

How To Replace UITabBar With UIToolBar?

I have a Tab Based App. When I am in a UIWebView, I want the TabBar to hide and be replaced with a UIToolBar.
Right now I utilize the following:
-(void)viewWillAppear:(BOOL)animated
{
[self.tabBarController.tabBar setHidden:YES];
self.navigationController.toolbarHidden = NO;
}
What this results in is the TabBar hiding the space it took is just blank white, and the toolbar is displayed above this blank white space. How can I fix this?
Set appropriate frame of the toolbar and then add in the main window in the application in viewDidAppear mathod

TableView selected background view switching orientations

I have a nib file that contains the view at 320 wide for portrait mode and it works fine.
cell.selectedBackgroundView = aView
I set the auto resize mask to allow the tableview to expand in landscape mode like so:
setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
but this does not expand the highlight view that remains at 320!
How do I get the highlight view to expand as well as the table view?
I have tried this:
[cell setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
but no good???
Thanks
selectedBackgroundView is a UIView too, meaning that it might help to aView.autoresizingMask = UIViewAutoresizingFlexibleWidth too.
Cheers!

How to add image in place of text in navigation bar?

How to add image in place of text in navigation bar ?
Can you use the titleView property of the UINavigationItem ?
UINavigationBar is a subclass of UIView. Thus, you can create your UIImageView object and add it as a subview in your UINavigation bar.
[navigationBar addSubview:imageView];
One thing you need to keep in mind that the navigationbar dimensions which is 320X44 in Portrait & 480X20 points in landscape for iPhone.
u can create an image view with some image and add it to the title view of navigation bar
like:--
self.navigationItem.titleView = myImageView;

Navigation Controller Transparent Bar Style is not working

I am using a navigation controller, and I have the style set to :
navController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
But when I run my program, the navigation controller looks like it is on top of a white background, not my background. When I push a controller, left or right, all my view, the current one, shifts to the top exactly the size of the navigation bar. And it is there where I can see my background through the navigation controller bar. Any ideas? When my barStyle is set to opaque, everything looks fine. I was thinking on setting my view frame a negative 'y' value, but I think there should a more elegant way.
I believe the UINavigationController assumes that your controller view frames don't include the area beneath the navigation bar.
UIBarStyleBlackTranslucent is more often used for UIToolbar, so Apple probably didn't make it easy to use it nicely with UINavigationBar. You'll probably need to abandon the UINavigationController, or start hacking the frames (careful with rotations), if you want to reliably render under the bar area.
Also, if your intention is to hide the navigation bar after a few seconds, you'll have a much easier time if you make it fade out (like the Photos app) instead of trying to slide it up (like Mobile Safari). Trust me on that one... that took me a lot of time to learn the hard way.
Simply use a transparent background image, and translucent = YES to allow the content to flow below the bar. Works on iOS 5 / 6. Add in viewDidLoad.
self.navigationController.navigationBar.translucent = YES;
UIImage * backgroundImage = [UIImage imageNamed:#"spacer.gif"];
[self.navigationController.navigationBar setBackgroundImage:(UIImage *)backgroundImage forBarMetrics:UIBarMetricsDefault];
I attached the spacer.gif image here, a single 1px x 1px transparent image.
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.169 green:0.373 blue:0.192 alpha:0.9];
self.navigationController.navigationBar.translucent = YES;
Note:
Don't use self.navigationBarStyle and self.navigationBarTintColor to change.
Add the last two statements to your viewDidLoad.
I ran into this same problem (in 3.1.3) and while you can't set the bar style after the navigationBar has already been setup you CAN set the tintColor and translucent values whenever you like:
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
self.navigationController.navigationBar.translucent = YES;
Will create the 'blackTranslucent' bar, I change the navigationBar look when I push certain view controllers onto the stack.
I had the same problem, and I solved it by making the background of the root view the same as my view. The white area behind the navigation bar turned out to be the root view.
The navigation controller offsets the coordinate sytem of all it's subviews so they draw below the navigation bar.
Extend your view's frame into the negative y domain for it to draw under the navigation bar.
You need to set the barstyle in your info.plist file for it offset everything correctly.
However, I haven't tried it since the 2.1 f/w was released, but when I tried this in 2.0 I found that the setting was lost after a rotation from portrait to landscape.
try to use this, may be it will helpful.
_topToolBar.barStyle = UIBarStyleBlackTranslucent;
_topToolBar.alpha = 0.3;
I had a same problem.I solved!
ImageViewExtendController *detailImageController = [[ImageViewExtendController alloc] init];
[detailImageController loadImage:url];
[self.navigationController pushViewController:detailImageController animated:YES];
If you set your nav controller's navigationBar to transparent in your App delegate early enough (It worked for me before adding the nav controller to the window), it will automatically shift your view up underneath the navigation bar.
Unfortunately it does not also shift your view underneath the status bar. Sad, it looks like you need to implement your own version of UINavigationController. Luckily, it's not too bad as UINavigationBar is pretty reusable.
Try this:
self.tabBarController.tabBar.superview.backgroundColor = [UIColor blackColor];
Change the Extend Edges options in child viewControllers
As for example, in xcode editor, go to your first viewcontroller child and unset the options:
Extend Edges;
Under Top Bars;
Under Bottom Bars;
Under Opaque Bars;
This way your child ViewController will not layout starting below the status bar of the navigation controller, neither the tabbar or the toolbars
hope it may help anyone