Why does all my UIViews have a grey bar at the bottom. I can hide it in runtime with the code self.navigationController.toolbarHidden = YES;
But I need it hidden in development mode. I have tried changing the navigation controller properties to bottom bar = non, did nothing.
How can I get rid of this grey bar at the bottom in development mode?
Select your navigation controller and open the attributes inspector. Make sure the Bottom Bar property is set to None.
You can also do the same for individual viewControllers.
Related
I'm working on an OSX app that supports a fullscreen mode.
The window is generated from a nib file but everything else is handled programmatically.
When I goes in fullscreen mode, my views resize properly but when the menu bar appear/disappear, setFrame don't get called for either the contentView or my own views. I'd to be notified
Is there a delegate to implement to catch those notifications? Or do I have to subclass NSWindow and find out how Safari handles its menu bar by reversing it?
It would be helpful to see some code, how exactly "your views resize properly".
But next info might help:
When a window goes fullscreen it occupies entire screen after the end of the fullscreen animation. The main menu bar shows over the window ("above" in sense of z-ordering). So when main menu bar shows/hides frame of your window and content view don't change.
Also note, that -[NSScreen visibleFrame] returns unoccupied frame. And it will not return whole screen frame until the end of the fullscreen animation.
After some researches, I could at least get ride of the dirty gray bar at the top of the screen by subclassing the window's content view and add the following code to the setFrame method, before call super:
//isFullscreen
if(([self.window styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask)
{
frameRect.size.height = self.window.frame.size.height;
frameRect.size.width = self.window.frame.size.width;
}
The window get resized to the screen size before setFrame get called, so we can use its size to update frameRect to window's size.
I have a UITableView as a subview of my custom UIViewController. I want to position it beneath the navigation bar, and when I scroll it I want it to be visibile in a translucent way through the navigation bar. To do this I should set the y of the table view to zero and set the property edgesForExtendedLayout to UIRectEdgeAll; in this way the things should work, because the UITableView should be set right beneath the navigation bar.
I have a big problem: if I set the y position to zero, the table view is positioned under the navigation bar, and the first part is partially hidden below the translucent bar. Also, if I set the y position to the height of the navigation bar, the table view could never be visibile through the navigation bar, because it starts from beneath the navigation bar.
Actually things work for UICollectionView, the y position is set to zero and when scrolling I can see the UICollectionView through the navigation bar.
Any suggestion about the problem? Is this an iOS 7 bug?
set the origin of the UITableView to 0 as you had and then its contentInset using the topLayoutGuide of the UIViewController.
That will probably look like this
self.tableView.contentInset = UIEdgeInsetsMake(self.topLayoutGuide.length, 0, 0, 0);
self.tableView.scrollIndicatorInsets = UIEdgeInsetsMake(self.topLayoutGuide.length, 0, 0, 0);
The usual story -- I'm making an iOS 5/6 app run under iOS 7 and the navigation bar behavior change is causing a problem.
The app already worked like the iOS 7 default with a full-screen view and a translucent nav bar "over" of the view. The problem is that hiding/un-hiding the nav bar causes different behavior in iOS 7. On iOS 5/6 hiding/un-hiding the nav bar does not change the view. On iOS 7, hiding the bar visually moves the view up leaving a blank bar at the bottom of the screen and un-hiding the bar moves the view back down to occupy the full screen (with the nav bar on top, of course).
I need to continue to support iOS 5 so I don't use auto layout, but I do use the full screen.
I have a view in which I'm viewing a zoomable image -- so the view controller has a fullscreen view containing a scrollView which contains an imageView.
The status bar is always hidden.
I get to the view controller via a navigation controller so there is a (black, translucent) navigation bar which lies over the top of my fullscreen view/scrollView/imageView.
After a brief delay some overlaying labels fade and the navigation bar is hidden
A single tap restores the overlay labels and un-hides the navigation bar.
This works on iOS 5/6 -- the navigation bar slides off the top of the screen uncovering the top of the view/image.
On iOS 7, when the navigation bar slides off the top of the screen the entire view visually moves up a corresponding amount (i.e. 44 points) leaving a black bar at the bottom of the screen. I can see this by setting a background color on the top-level view and resizing the scrollview enough to see the background; the top of the view does indeed move offscreen and the background color is not drawn over the bottom (44 points) of the screen.
BUT, self.view.frame doesn't change and remains at {0, 0} 320 x height.
When I single-tap to restore the overlay info and navigation bar the view moves back down to occupy the full screen and the translucent nav bar is over the top of the view/image.
Nothing I've tried changes the behavior:
Changing the IB view controller layout controls (Under top bars, Under bottom bars, Adjust scroll view insets). Building for 5.1, 6.1, and 7.0 all produce the same result when run under 7.0.
self.edgesForExtendedLayout = UIRectEdgeNone
does nothing. Using the layout delta values doesn't do anything. In IB the view looks the same when "viewed as" iOS 7 and iOS 6 and earlier. I print out a lot of debug info but nothing about the view (or scroll view) seems to change when the view moves "off screen".
The code that shows the overlay info (run when the view is first shown and on single-taps) is:
- (void) showOverlayInfo {
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
[[[self navigationController] navigationBar] setTranslucent:YES];
[[self navigationController] setNavigationBarHidden:NO animated:NO];
overlayInfoHidden = NO;
overlayInfoFading = NO;
self.infoButton.hidden = NO;
self.infoButton.alpha = 1;
self.descriptionLabel.hidden = NO;
self.descriptionLabel.alpha = 1;
}
The code that hides the overlay info is:
- (void) hideOverlayInfo {
overlayInfoHidden = YES;
overlayInfoFading = NO;
self.infoButton.hidden = YES;
self.descriptionLabel.hidden = YES;
[[self navigationController] setNavigationBarHidden:YES animated:YES];
}
So can anybody tell me what (presumably simple) thing I'm missing?
I finally found my problem.
The key fact is that the image-viewer view controller was in a UIPageViewController,
so what I was looking at and experimenting with was really "inside" another view controller.
Although I had disabled the view controller setting Adjust Scroll View Insets for the image viewer VC, I hadn't done it for the containing VC that created the UIPageViewController and the UIPageViewController presents the pages in some subclass of a UIScrollView. When I changed them for the parent VC, the problem vanished.
So I think the moral of the story is to:
Think about the problem more globally when local doesn't work because maybe you're missing some important context.
If you don't want to use the iOS 7 behavior, change the settings for every single view controller you have!
How to change the width of UITabBarItem?
I have an item with the title, that is wider than default item width. How can I fix it?
Solution for iOS7 and greater versions:
A new property has been introduced for UITabBar: itemWidth.
Set the itemWidth to a positive value to be used as the width for tab
bar items when they are positioned as a centered group (as opposed to
filling the tab bar). Default of 0 or values less than 0 will be
interpreted as a system-defined width.
#property(nonatomic) CGFloat itemWidth NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR;
So you can do this in your AppDelegate:
[[UITabBar appearance] setItemWidth:WIDTH];
If you want to fill the whole UITabBar:
[[UITabBar appearance] setItemWidth:self.window.frame.size.width/NUMBER_OF_ITEMS];
You can change the spacing (and width) of the tab bar items by subclassing UITabBar and overriding its layoutSubviews method. You will find all tab bar buttons in the self.subViews array. Their class is the non-public UITabBarButton but they inherit from UIControl so you can identify all tab bar buttons checking if they are kind of UIControl class. Then all you need is to change the frame of the tab bar buttons.
I just searched through the documentation and saw no method for adjusting the UITabBarItem's width.
A possible solution would be to place a view within the tab bar controller to load a custom UITabBarItem, that is the proper width.
Found easier solution for swift if you subclass the UITabBarController
this will autofill the tab bar items evenly
self.tabBar.itemPositioning = .fill
Swift 5
UITabBar().itemWidth = self.window!.frame.size.width/5
What is the proper way to implement the status bar and navigation bar that go on top of an UIView?
alt text http://img.skitch.com/20081217-t78sdixk37hqgdh1ia2fgec4st.png
Just set “wants fullscreen layout” in your view controller. That solves the problem for me.
self.wantsFullScreenLayout = YES;
In the screenshot above, there's a translucent status bar and a translucent navigation bar.
The status bar is set using
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackTranslucent];
The navigation bar is set using
theNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
If you have a view controller inside a navigation controller, and you want to hide the status bar in order to have your viewController's view in full screen, you can always call :
[self.navigationController.view setNeedsLayout];
after hiding the status bar.
But I personally think
[self setWantsFullScreenLayout:YES];
is a better way.
The best way I came up was this: when using a "complex" hierarchy of Tab bar containing navigation controllers, with one "detail" view being a full screen view.
In the app delegate just before the tab bar controller's view is added to the window, I added this:
tabBarController.view.frame = [[UIScreen mainScreen] bounds];
This will make the tab bar controller cover the entire screen, even below the area of the status bar. I had to offset heights of several views to +20px, notably the navigation bars.
Set the statusbar style as black translucent and navigation bar style as black translucent. If you are using a navigation-based application, in the MainWindow.xib check the status bar is hidden and navigation bar is hidden checkboxes.
When the user touches the screen, start a timer to see if this was a single tap or double tap. If a single tap, make the statusbar and navbar hidden = NO. and once user activity stops, start a timer again. after some time of no activity, make them hidden again.
step 1 Set the UIViewControllerBasedStatusBarAppearance to No in the plist
Then add the following code in did finish launch option
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
[application setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.clipsToBounds =YES;
self.window.frame = CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
}
Please follow this code it worked for me