How can I get the navigationbar in my iPhone application to match the one in other apps such as Safari as the time and bar are merged. Here's what mine looks like compared to MobileSafari.
Safari
My App
Thanks for your help! (:
This is a common problem and I had the same, but solved very easily by just setting the UINavigationBar Y-position to 20px and not to 0px. Then you have to assign the UINavigationBarDelegate to your ViewController:
[_navigationBar setDelegate:self];
Furthermore you have to add this method to your ViewController, which will be called because of the Delegate assignment:
-(UIBarPosition)positionForBar:(id<UIBarPositioning>)bar
{
return UIBarPositionTopAttached;
}
It looks like you did It already. Safari just has a UITextField instead of a title label in the center. Navigation bars are now 64px in height for iOS 7 and automatically go under the navigation bar
Related
I would like to customise the bottom bar of the UITabBarController to like this:
How can I achieve this? Thanks!
I think this web page would be of some value to you:
Recreating the raised Center Tab Bar Button...
This should be easy on iOS 5xx and above. You need to look at the UIAppearance proxy methods which allow skinning of Apple default UIKit elements.
UITabBar has
#property(nonatomic,retain) UIImage *backgroundImage
UITabBarItem has
- (void)setFinishedSelectedImage:withFinishedUnselectedImage:
- (void)setTitlePositionAdjustment:
I wasn't lucky with searching for this, so here we go ;)
I have a UIViewController with a custom UINavigationBar which pushes another UIViewController as subview.
Everything works fine except when I click the back button on the subview. The previews (first) view appears correctly, but not animated. The animation of the UINavigationBar is correct, only the views switch immediately.
The function - (void)viewWillAppear:(BOOL)animated of the first UIViewController gets called with NO for animated. This only happens when I test with iOS 5, not with iOS 4.
Does anyone know how to fix this?
Thanks for your help! Hannes
UPDATE 1
I just removed all custom code and just used the plain UINavigationBar (so no extra settings) and it still doesn't work with iOS 5. This is my code I use in the first ViewController to push the second ViewController:
[self.navigationController pushViewController:secondViewController animated:YES];
As I already mentioned - when I click the back button in the navigation bar on the second view the first view appears immediately without animation.
Any help would be appreciated! Thanks!
UPDATE 2
I feel like I'm getting closer to the issue, but still no solution:
I just added a custom UINavigationController where I just call [super popViewControllerAnimated:animated]. This get's called correctly (animated is YES) but the viewWillAppear of the first UIViewController gets NO as value for animated...
I was having a similar problem today where the UIViewController was getting NO in viewWillAppear, except with the standard UINavigationBar and UINavigationController.
It turned out to be due to manually calling viewWillAppear:YES somewhere it shouldn't have been. This item suggests that it can also be caused by calling the wrong super method somewhere (e.g. [super viewWillAppear:animated] instead of [super viewDidAppear:animated] inside of viewDidAppear).
As for using a custom UINavigationBar, I ran across this link today that may help your case: http://sloshire1.posterous.com/simple-fix-for-viewwillappear-in-ios5
Apple implemented official ways to create custom navigation bars in iOS 5. Unfortunately, they also broke most of the non-official ways of doing it in iOS 4. iOS 5 won't call drawRect for you anymore. You need to have two ways of doing it, one for iOS 5 and greater, using the new calls, and one for iOS 4 and earlier, using the old calls. Check out the documentation for custom navigation bars in iOS 5 for more info.
Did you try to remove all your custom code and go with the native navigation bar? Does the behavior stay the same? This way you can check if your custom bar messes with the transition.
I would like to know that how can we mimic the UI of iOS game center app? It has a very cool interface. I wonder how they are drawing text, Custom Tab Bar Controller etc.
Creating a custom UITabBarController like that of Game Center is possibly the hardest of all iOS customisation techniques, and will more than likely need a complete custom component building from scratch. Unfortunately Apple do not want you to mess with the UITabBarController much.
See this answer iOS TabBar Image assignment for how to change the tint color of the tab bar.
The rest is fairly straight forward and can be found out about on here, custom UINavigationItem for the UINavigationBar and basic UIWebView and UILabels will help you achieve everything else.
Hope this helps
I found the best approach was to create my own tab bar controller.
While it's not trivial, it is straightforward once you attempt it. For the "tab bar", I used a plain UIView. Inside the UIView I placed a UIImageView (to hold the tab bar background image--can be anything you want) and several UIButtons (for each tab button--very customizable since each is a UIButton). Doing it this way lets you do anything you want in terms of tab bar appearance.
You can use this trick to customize your nav bar background
-(void)styleNavBar:(CGImageRef)backgroundImage
{
navBar.layer.contents = (id)backgroundImage ;
}
Also, for custom nav bar buttons:
UIButton * customButton ; // your custom left or right nav bar button
// put it into a bar button item:
UIBarButtonItem * barButtonItem = [ [ UIBarButtonItem alloc ] initWithCustomView:customButton ] ;
That should be a good start!
I'm developing an iPhone app with Objective-C and iOS SDK with a tab view on the bottom. I want to make the app so that when it first loads up, the tabs are on the bottom, but none of them are selected. Instead, the user is presented with a "home" view, and can select the tabs from there if he / she desires.
How would I make this work? I'm assuming it's something in the App Delegate?
Thanks!
I did this recently. Just do
[self.myTabBar setSelectedItem:nil];
Works perfectly, no tabs should be selected. Let me know if you have any problems. Also, just put that in either - (void) viewDidLoad or initWithNibName .
I think this would be something that's appropriate to fake.
I would:
Add a subview that overlays the area normally occupied by the selected tab view.
Add UITabBarControllerDelegate tabBarController:shouldSelectViewController that will hide/remove that view.
The only remaining problem is to make the actually selected tab button seem unselected until the subview is hidden.
i'm having a real trouble with UITabBarController. I have a simple foto app, and I'm trying to simulate almost the same behaviour as the PhotoApp from the Iphone
the main view controler is the tabbar itself, i also have a NavBar and a status bar on top.
What i want is on tap to hide the bars (not with timer, just on tap).
The photo is actually an UIScroll view that zooms the photo or makes it again 1:1. that part already works,
I've tried before pushing the view to the navbar to set the hidesBottomBarWhenPushed and well it works, but i can't set a custom animation, and that's not the real problem , I can't show again the bars, they dissapear and i don't know how to reshow them, i'm sure i'm probably missing someting very obvious, but as my experience in obj C is little like half a year part time, i thought i asked here as stackoverflow seems to get the answers :)
Something to investigate: the Three20 project: http://github.com/facebook/three20 - it includes a completely clone of the photo-browsing app in component form.
But without Three20, you can't do this with a stock UINavigationController, because the UIViewController that you're using is a subview of the UINavigationController. You need to make a sibling view on another layer. To do this, make a parent UIViewController which has two subviews: your photo, and a UIToolbar. You can hide and display the UIToolbar by setting it's hidden property, and make sure it's above the photo view with [parent.view bringSubviewToFront:toolbarController] (where parent is the main UIViewController that contains both the photo view and the UIToolbar)