Status bar and navigation bar issue in IOS7
Fix for status bar issue in IOS 7
Finally I fixed the status bar over lap issue using the delta value property in xcode5. First I have increased origin - y 20pxl to all the controller used in the Xib (it seams to be working fine only in IOS 7), after that I set the delta value for all the view controller origin -y to -20 it works fine in both iOS 6 and iOS 7.
Steps to do that.
Xcode 5 provide preview option to view the appearance of the xib in different view based on the OS version.
Choose preview option from assistant editor
Click assistant editor
and choose preview option to preview selected view controller in different version.
view controller view preview option.
in preview you can find the toggle option to preview view in different version. In preview u can feel the status bar issue clearly if its not fixed properly by toggle the version.
Three steps to fix the status bar issue:
step 1: Make sure the view target us 7.0 and later in File inspector.
Step 2 : Increase the origin - y with 20 pixel (exactly the size of the status bar) for all the controls added in the view controller.
Step 3 : Set the delta value of origin y to -20 for all the controls then only it will adjust automatically based on the version. Use preview now and feel the differ that the controls automatically adjust because of the delta value.
Once the status bar issue fixed, issue while presenting the model view (ZbarSDk controller) is also fixed automatically.
Preview screen :
iOS 7 Status Bar Collides With NavigationBar
The latest version of the iOS has brought many visual changes and from a developer's point of view, the navigation and status bar are two noticeable changes.
The status bar is now transparent and navigation bar behind it shows through. The navigation bar image can even be extended behind the status bar.
First of all, if you are a beginner and have just started iOS development and are confused the way status bar and navigation bar is working, you can simply go through a blog post HERE that i found very useful. It has all the information related to navigation and status bar in iOS 7.
Now coming to the answer of your question. First of all i can see two different problems. One is that your status bar and navigation bar are both kind of colliding with each other as shown by you in the question with an image.
PROBLEM: Well the problem is that your have earlier dragged a navigation bar in your view controller which was working in iOS 6 correctly but with the arrival of iOS 7 SDK, this approach is resulting in status bar and navigation bar overlapping with each other.
SOLUTION to First Problem: You can either use UIBarPositionTopAttached or you can use view bounds and frames, i can also suggest and link you to Apple's documentation and bla bla bla but that would take some time for you to solve the issue.
The best and the most easiest way to solve this issue is to just embed your view controller inside a navigation controller and thats it. You can do it by just selecting the view controller and going to Editor > Embed In > Navigation Controller. (If there is any content on your old navigation bar, you can first drag it down, embed the view controller in navigation controller and then move the bar buttons on the new navigation bar and then delete the old navigation bar)
SOLUTION to Second Problem: This solution is for your specific question that you have mentioned in the update and is not for the general public reading this. As you can see that navigation and status bar is not visible and a transparent area is showing the parent view controller. I am not really use why you are facing this issue but most probably because of some third party library like ECSlidingView or any other is involved. You can select this view controller in your storyboard and set the background color of the view to be the same as your navigation bar. This will stop showing the parent view controller behind and your navigation bar and status bar will start showing. Now you can cover the rest of your view controller with text view or what ever your are using in it.
Hope this helps!
Status bar and navigation bar appear over my view's bounds in iOS 7
You can achieve this by implementing a new property called edgesForExtendedLayout
in iOS7 SDK. Please add the following code to achieve this,
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
You need to add the above in your -(void)viewDidLoad
method.
iOS 7 brings several changes to how you layout and customize the
appearance of your UI. The changes in view-controller layout, tint
color, and font affect all the UIKit objects in your app. In
addition, enhancements to gesture recognizer APIs give you finer
grained control over gesture interactions.Using View Controllers
In iOS 7, view controllers use full-screen layout. At the same time,
iOS 7 gives you more granular control over the way a view controller
lays out its views. In particular, the concept of full-screen layout
has been refined to let a view controller specify the layout of each
edge of its view.The
wantsFullScreenLayout
view controller property is deprecated in
iOS 7. If you currently specifywantsFullScreenLayout = NO
, the view
controller may display its content at an unexpected screen location
when it runs in iOS 7.To adjust how a view controller lays out its views,
UIViewController
provides the following properties:
- edgesForExtendedLayout
The
edgesForExtendedLayout
property uses theUIRectEdge
type,
which specifies each of a rectangle’s four edges, in addition to
specifying none and all. UseedgesForExtendedLayout
to specify which
edges of a view should be extended, regardless of bar translucency. By
default, the value of this property isUIRectEdgeAll
.
- extendedLayoutIncludesOpaqueBars
If your design uses opaque bars, refine
edgesForExtendedLayout
by
also setting theextendedLayoutIncludesOpaqueBars
property to
NO. (The default value ofextendedLayoutIncludesOpaqueBars
is NO.)
- automaticallyAdjustsScrollViewInsets
If you don’t want a scroll view’s content insets to be automatically
adjusted, setautomaticallyAdjustsScrollViewInsets
to NO. (The
default value ofautomaticallyAdjustsScrollViewInsets
is YES.)
- topLayoutGuide, bottomLayoutGuide
The
topLayoutGuide
andbottomLayoutGuide
properties indicate the
location of the top or bottom bar edges in a view controller’s view.
If bars should overlap the top or bottom of a view, you can use
Interface Builder to position the view relative to the bar by creating
constraints to the bottom oftopLayoutGuide
or to the top of
bottomLayoutGuide. (If no bars should overlap the view, the bottom of
topLayoutGuide
is the same as the top of the view and the top of
bottomLayoutGuide
is the same as the bottom of the view.) Both
properties are lazily created when requested.
Please refer, apple doc
iOS 7 | Navigation bar / Toolbar buttons very close to status bar
The navigation bars or toolbars have to be at (0, viewController.topLayoutGuide.length
) with bar positioning of UIBarPositionTopAttached
. You should set the delegate of your navigation bar or your toolbar to your view controller, and return UIBarPositionTopAttached
. If positioned correctly, you will have the result in your third image.
More information here:
https://developer.apple.com/documentation/uikit/uibarpositioningdelegate?language=objc
Related Topics
Ios: How to Make a Shadow for Uiview on 4 Side (Top,Right,Bottom and Left)
Best Way to Check If Object Is Out of Bounds in Array
How to Pass Prepareforsegue: an Object
How to Take a Screenshot Programmatically on Ios
Fast and Lean Pdf Viewer For Iphone/Ipad/Ios - Tips and Hints
When Should I Compare an Optional Value to Nil
How to Localise a String Inside the iOS Info.Plist File
How to Write a File to a Folder Located At Apple'S Files App in Swift
Draw Text Along Circular Path in Swift For Ios
Wkwebview Not Loading Webpage - Renders Blank Screen in Swift
Swift - Integer Conversion to Hours/Minutes/Seconds
How to Change Status Bar Text Color in Ios
Performselector May Cause a Leak Because Its Selector Is Unknown
How to Present Uialertcontroller When Not in a View Controller
Uiimage(Contentsoffile:) Returning Nil Despite File Existing in Caches Directory
Swift - Get Device'S Wifi Ip Address
How to Preserve Identifierforvendor in iOS After Uninstalling iOS App on Device