iPhone 5 屏幕尺寸变长指南
来源:互联网 发布:淘宝代购手表是真的吗 编辑:程序博客网 时间:2024/05/10 00:28
原文地址:http://www.cnblogs.com/pinping/archive/2012/10/12.html(感谢原作者的奉献)
NSLog(@"applicationFrame%f",[UIScreenmainScreen].applicationFrame.size.height);
可以的到整个程序的View的大小
NSLog(@"navigationBar%f",self.navigationController.navigationBar.frame.size.height);
NSLog(@"navigationBar%f",self.tabBarController.tabBar.frame.size.height);
floatheightEg = [UIScreenmainScreen].applicationFrame.size.height -self.navigationController.navigationBar.frame.size.height -self.tabBarController.tabBar.frame.size.height;
LeftView*lView=[[LeftView alloc] initWithFrame:CGRectMake(0, 0, 56, heightEg) Number:1];
[self.view addSubview:lView];
现在的lView就个适用iPhone 4/S 和iPhone 5那;
因为的程序里面有navigationController和tabBarController所以要减去navigationController和tabBarController的高度;
来自:http://www.devdiv.com/iOS_6_Auto_Layout_NSLayoutConstraint_界面布局-weblog-227936-13173.html
终于ios 6推出了正式版本,同时也随之iphone5的面试,对于ios开发者来说,也许会感觉到一些苦恼。那就是原本开发的程序,需要大量的修改了。为了适应最新的iphone5的屏幕。
在WWDC2012里苹果推出了,Auto Layout的概念。我们可以通过Auto Layout来适应屏幕的改变。
比如我们要做一个如下的界面。
如果按照以前的frame的方式的话,大概代码如下
[代码]c#/cpp/oc代码:
01
UIView *myview = [[UIView alloc] init];
02
myview.backgroundColor = [UIColor greenColor];
03
UIView *redView = [[UIView alloc] init];
04
redView.backgroundColor = [UIColor redColor];
05
UIView *blueView = [[UIView alloc] init];
06
blueView.backgroundColor = [UIColor blueColor];
07
[myview addSubview:redView];
08
[myview addSubview:blueView];
09
redView.frame = CGRectMake(50, 80, 100, 30);
10
blueView.frame = CGRectMake(180, 80, 100, 30);
11
self.view = myview;
通过上面的代码我们就能很简单的实现上面的布局效果了,但是使用auto layout的时候我们需要使用如下代码来实现。
[代码]c#/cpp/oc代码:
01
UIView *myview = [[UIView alloc] init];
02
03
myview.backgroundColor = [UIColor greenColor];
04
05
UIView *redView = [[UIView alloc] init];
06
07
redView.backgroundColor = [UIColor redColor];
08
09
UIView *blueView = [[UIView alloc] init];
10
11
blueView.backgroundColor = [UIColor blueColor];
12
13
[myview addSubview:redView];
14
15
[myview addSubview:blueView];
16
17
[myview setTranslatesAutoresizingMaskIntoConstraints:NO];
18
19
[redView setTranslatesAutoresizingMaskIntoConstraints:NO];
20
21
[blueView setTranslatesAutoresizingMaskIntoConstraints:NO];
22
23
NSMutableArray *tmpConstraints = [NSMutableArray array];
24
25
[tmpConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:
@"|-50-[redView(==100)]-30-[blueView(==100)]"
options:0 metrics:nil views:NSDictionaryOfVariableBindings(redView,blueView)]];
26
27
[tmpConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:
@"V:|-30-[redView(==30)]"
options:0 metrics:nil views:NSDictionaryOfVariableBindings(redView)]];
28
29
[tmpConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:
@"V:|-30-[blueView(==redView)]"
options:0 metrics:nil views:NSDictionaryOfVariableBindings(blueView,redView)]];
30
31
[myview addConstraints:tmpConstraints];
32
33
self.view = myview;
最后对于向下兼容的时候我们可以通过
[代码]c#/cpp/oc代码:
1
if
([myview respondsToSelector:@selector(addConstraints:)]){
2
3
//支持auto layout
4
5
}
else
{
6
7
//不支持
8
9
}
- iPhone 5 屏幕尺寸变长指南
- iPhone 5 屏幕尺寸变长指南
- Cocoa Iphone 屏幕尺寸
- iPhone屏幕尺寸
- iPhone屏幕尺寸
- iPhone屏幕尺寸
- iphone屏幕尺寸
- iPhone屏幕尺寸
- iphone屏幕尺寸
- iphone 各种屏幕尺寸
- iPhone屏幕尺寸
- iphone屏幕尺寸
- 不同iPhone屏幕尺寸
- iphone屏幕尺寸总结
- IOS iPhone、iPad屏幕尺寸
- Iphone手机各屏幕尺寸
- iPhone各版本屏幕尺寸
- iPhone屏幕尺寸和分辨率
- Struts2中的struts.multipart.saveDir的配置
- 更改ubuntu ipv6 地址
- 关于除法与乘法逆元关系的一些理解
- Android Read-only file system 错误处理
- c++ 作用域
- iPhone 5 屏幕尺寸变长指南
- Java 之 String 类型
- Android应用程序的默认最大内存值
- 软件工程-面向对象设计与法则
- 《Windows核心编程系列》十异步IO之IO完成端口
- Android学习备忘008——使用剪切板传递数据
- JavaScript_Math对象
- Java 之 Array 数组
- debugview + outputdebugstring 调试程序 同时也可以输出调试日志文件