IOS7 UIScrollView & UINavigationController
来源:互联网 发布:mac触控板右键 编辑:程序博客网 时间:2024/05/18 07:44
解决IOS7 带来的导航栏问题,以及UIScrollView 布局问题~
实例:
I recently downloaded Xcode 5 DP to test my apps in iOS 7. The first thing I noticed and confirmed is that my view's bounds is not always resized to account for the status bar and navigation bar.
In viewDidLayoutSubviews
, I print the view's bounds:
{{0, 0}, {320, 568}}
This results in my content appearing below the navigation bar and status bar.
I know I could account for the height myself by getting the main screen's height, subtracting the status bar's height and navigation bar's height, but that seems like unnecessary extra work.
How can I fix this issue?
Update:
I've found a solution for this specific problem. Set the navigation bar's translucent property to NO:
self.navigationController.navigationBar.translucent = NO;
This will fix the view from being framed underneath the navigation bar and status bar.
However, I have not found a fix for the case when you want the navigation bar to be translucent. For instance, viewing a photo full screen, I wish to have the navigation bar translucent, and the view to be framed underneath it. That works, but when I toggle showing/hiding the navigation bar, I've experienced even stranger results. The first subview (a UIScrollView) gets its bounds y origin changed every time.
解决方案:
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 specify wantsFullScreenLayout = 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 the UIRectEdge
type, which specifies each of a rectangle’s four edges, in addition to specifying none and all. Use edgesForExtendedLayout
to specify which edges of a view should be extended, regardless of bar translucency. By default, the value of this property is UIRectEdgeAll
.
- extendedLayoutIncludesOpaqueBars
If your design uses opaque bars, refine edgesForExtendedLayout
by also setting the extendedLayoutIncludesOpaqueBars
property to NO. (The default value of extendedLayoutIncludesOpaqueBars
is NO.)
- automaticallyAdjustsScrollViewInsets
If you don’t want a scroll view’s content insets to be automatically adjusted, set automaticallyAdjustsScrollViewInsets
to NO. (The default value of automaticallyAdjustsScrollViewInsets
is YES.)
- topLayoutGuide, bottomLayoutGuide
The topLayoutGuide
and bottomLayoutGuide
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 of topLayoutGuide
or to the top of bottomLayoutGuide. (If no bars should overlap the view, the bottom oftopLayoutGuide
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
- IOS7 UIScrollView & UINavigationController
- IOS7、IOS6 UINavigationController遮挡
- ios7 UIScrollView 尺寸问题
- ios7 UIScrollView 尺寸问题
- ios7 uiscrollview不能滚动
- UINavigationController 和 UIScrollView新特性
- UINavigationController在ios7的变化
- iOS7 UIScrollView 适配问题
- UINavigationController详解(四)iOS7新特性
- UINavigationController详解(四)iOS7新特性
- ios7 UIScrollView 尺寸问题------UIScrollView的子视图整体下移
- IOS7 系统下的UIScrollView偏移问题
- IOS7下 UIScrollView子View下移
- ios7 uitableview\uiscrollview内容视图下移
- iOS7以后NavigationBar下的UIScrollView
- UINavigationController + UIScrollView组合,视图尺寸的设置探秘(一)
- UINavigationController + UIScrollView组合,视图尺寸的设置探秘(二)
- UINavigationController + UIScrollView组合,视图尺寸的设置探秘(三)
- Where am I? You need to setup your server names in class.config.php $_SERVER['HTTP_HOST'] reported
- 软件滤波的方法及使用的优缺点
- 你是否曾经遇到过突然找不到房间钥匙的情况?亦或者,在需要付钱的时候发现钱包不见了?
- 用OpenSceneGraph实现的NeHe OpenGL教程 - 第二十课
- 第八周——用友元类完成重载
- IOS7 UIScrollView & UINavigationController
- myeclipse这几天每次启动项目就已debug模式进入classNotFoundException(没加断点)
- GHUnit for iOS测试指南
- 人生是快乐的 悲哀没什么大不了
- 在XC2440上实现使用U盘自动更新系统的uboot
- 齐白石晚年自省
- Spring整合Hibernate
- #import,#pragma comment, loadLibrary" 三种引入dll的方式都分别在什么时候使用
- 一个vim的配置文件