In iOS 7.1, there's empty gap on the left and right navigation bar.
In iOS 8.4 it displayed correctly without any gap.
How to fix this in iOS 7.1?
It's in UITableViewController
I don't use storyboard
Code:
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.titleView = UISearchBar()
}
I'm going to ignore the childish back-and-forth in the comments. What you're seeing is the default dimensions of the search bar. What you should be doing is setting the search bar's frame to be equal to the navigation bar's, but you have to beware of two things: not to include the status bar's dimensions, which get tacked onto the nav bar when the view is displayed, and to handle resizing gracefully, because nav bars (obviously) have different sizes in portrait or landscape mode.
Despite all this, let me just say that putting a search bar in the nav bar is a colossally bad UI decision, and it violates Apple's Human Interface Guidelines.
Related
I have a problem with my app development in Xcode 11.3. I'm developing an app targeting iOS 13.2, and I've edited the navigation bar so that its background is black. However, I can't seem to find a way to delete or hide the title bar. Now it just looks like a big black bar.
All the other content is served over a webview, so that's why I'd need to remove the title bar but not the black background color in the navigation bar (where the time and battery, etc. are displayed). I hope you can help.
Here's the preview currently:
Thanks!
So it sounds like you want something like this:
So, in that screen shot:
We're in a navigation interface, but the navigation bar is hidden.
The green view is a stand-in for your "Aleksis" view. Its top is pinned to the bottom of the safe area.
There is also a black view. Its top is pinned to the top of its superview (the view controller's main view) and its bottom is pinned to the bottom of the safe area. It is behind the green view.
Here's the storyboard configuration I used:
Here's the view controller code:
override var preferredStatusBarStyle: UIStatusBarStyle { .lightContent }
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.isNavigationBarHidden = true
}
I am trying to show a top bar in Xcode 9 Swift 4. In my storyboard it shows the top bar as in the below picture:
but when I run it I get this with no top bar:
I tried to use a navigation bar just with a title but it shows as:
the carrier, wifi, time, and battery background is still white. If I set the navigation bar to the top of the screen, it will cover them like:
Why the top bar is not showing? How can achieve something like this?:
UPDATE
Top bar is not a navigation bar. It is kind of just a bar that shows a title. As you can see in the below picture, the register scene doesn't have a navigation bar. I added the top bar from the properties on the right side.
In your second to last screen, where you show that the navigation bar covers it:
It does not really cover it - but the text of the status bar is black, so you cannot see it. To change it, in the implementation of the GrolocationNewsViewController (or whatever you call it) override preferredStatusBarStyle and return .lightContent:
class GrolocationNewsViewController: UIViewController {
// rest of the code
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
}
I have used the code from #Milan Nosáľ answer and it does show the status in white. Then used #Ameya Vichare answer on this link while I was looking for a way to increase the navigation bar height
How to change navigationBar height in iOS 11? turn out it is a bug in Xcode 9. Now it shows like what I wanted:
I am working on Xamarin Studio with Mono but you can respond in Obj-C or Swift I don't mind. (Please don't mind the icons, design, translations, etc on the screenshots this is WIP)
I have this strange issue I can't resolve :
A white blank space appears under the top bar of my UIView which is in a UITabBarController, at first I thought it was the "Adjust Scroll View Insets" option enabled but it is not. I also tried to remove my UIWebView and try with a Label, same problem.
The blank space only appears on views that are "tabbed" in the "Others" section of my UITabBarController (when the screen is too small). You can see on my screenshots on an iPad the white space is not here, but on every other devices (iPhone, iPhone plus) it appears !
I can put a negative top constraint if the device is not an iPad but it is not the proper way to remove it ...
You can find the screenshots of (in order) :
The storyboard view
Top Constraint of the WebView
The whitespace on iPhone (but not on iPad and Storyboard, shouldn't be here !!)
StoryBoard structure
No whitespace on iPad (this is the normal behaviour, I want it on smaller devices too)
ViewController parameters
That by sight the white space is exactly the nav bar is a giveaway that in adjusting for those bars something is awry.
There is a contradiction in your layout that is probably the source of the issue. You have "extend edges" selected for the map view, but you have the top of the map view constrained to the top layout guide. The top layout guide is located at the bottom of the nav bar, so if something was adjusting insets for being under the bar, and knew the bar height and assumed it was under the bar, then this would result.
That wouldn't explain why it looks correct when included in the tab bar's initial view controllers, but it's possible when it appears from more pop-up, it is added to the view hierarchy so quickly it doesn't know the exact position of the top layout guide or the top bars, and so causes the glitch, whereas in the tab bar controller tabs it makes that adjustment on one of multiple layout passes.
Thank you for your answers, I found out what was that white space.
If I want to remove it I have to uncheck "Extent edges - Under Top Bars" and then do (or the NavigationBar will be gray, see Dark shadow on navigation bar during segue transition after upgrading to Xcode 5.1 and iOS 7.1):
NavigationController.NavigationBar.Translucent = false;
But trying to resolve the issue, I tried the following code :
ParentViewController.NavigationController.NavigationBar.Translucent = false;
And the white space turned into a second NavigationBar with tools to reorganize the tabs, and no need to uncheck "Extent edges - Under Top Bars" (especially if you don't set the tranlucent to false because the second navigation bar will go under it).
I will keep that second NavigationBar (https://developer.apple.com/reference/uikit/uitabbarcontroller/1621183-morenavigationcontroller), I like it. But for some reason it wasn't displayed until I set the ParentViewController NavigationController NavigationBar Translucent to false ... I don't really get why, it should have appeared directly but ...
Note that the proper way to display this NavigationBar if it is not displayed by default is to add the line in the UITabBarController class, and not in each ViewController ...
public partial class TabBarController : UITabBarController
{
public TabBarController(IntPtr handle) : base(handle)
{
}
public override void ViewDidLoad()
{
CustomizableViewControllers = null; //if you want to disable the edit button
NavigationController.NavigationBar.Translucent = false;
base.ViewDidLoad();
}
}
(Sorry for the french on the screenshots my device is in French ..)
I have a modally presented view controller which is not in the navigation stack but needs a navigation bar to cancel the selection. The VC is presented by another VC which is a popup (a real one not a fullscreen view). I need a navigation bar in it to present a title and a cancel-button in the upper right hand corner just like the standard camera roll image picker has it.
Here's what I tried so far:
I added the navigation bar manually by dragging it to the view in the storyboard and attached it with constraints. That works great but the problem is that the navigation bar is too small. It doesn't mind the status bar above it so the cancel button and the title are very close (almost overlapping) to the status bar.
Tried to increase the navigation bar's height but apple doesn't allow changing the frames of navigation bars.
Tried push it down a bit with constraints but that results in a white background color for the status bar since the controller has a white background.
Implemented a new navigation controller just for the one view that needs the bar. But that will give me a standard navigation bar with an arrow in the top left corner which doesn't really fit the navigation feeling since the view is presented modally (from the bottom). Also this seems to be a bit much overhead.
What can I do to achieve a camera-roll-like navigation bar?
BTW: I work with swift.
EDIT:
I tried this but setting the height value fails obviously since it's not allowed.
#IBOutlet weak var navigationBar: UINavigationBar!
override func viewDidLoad() {
navigationBar.frame.height = 44.0
}
I actually found a solution to this:
Set the VC as the delegate for the navigation bar
Conform to protocol UIBarPositioningDelegate
Implement
func positionForBar(bar: UIBarPositioning) -> UIBarPosition {
return .TopAttached
}
Push the navigation bar down with constraints by 20p
Voila
I developed a simple app for iOS6 and now I'm to updating its appearence for iOS7. One of the first changes I would like to do concerns the navigation bar.
I'm using the standard navigation bar UI component that comes with xcode. While in iOS6 the navigation bar was clearly placed under the status bar (i.e. battery, carrier and hour), in iOS7 the navigation bar blends with the status bar.
My question is: how can I increase the height of the navigation bar and place the title vertically a little lower than the default position?
Currently I have this:
And the title is too close to the time. I would like to achieve this (standard Photos app that comes with iOS7):
here the title of the bar is lower and the bar is larger (or is just shifted down).
It have been trying to modify the height of the navigation bar through the size inspector but with no success.
It's probaly a very easy issue to solve, however I'm still new to xcode development and I can't figure it out.
Stick the view controller in a Navigation Controller, that should immediately solve the problem