iphone开发之横屏与竖屏在不同视图之间的切换
来源:互联网 发布:商业银行 数据质量 编辑:程序博客网 时间:2024/05/21 19:47
有两个视图,横屏视图和纵屏视图,当iphone的方位变化的时候,这两个视图相互切换。
1。两个视图:PortraitView和LandscapeView ,分别标示纵屏和横屏。
2。一个控制器,RootViewController,根控制器。
3。在RootViewController.m中有以下代码
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
[landscape removeFromSuperview];
[self.view addSubview:portrait];
}
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
[portrait removeFromSuperview];
[self.view addSubview:landscape];
}
}
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
UIControl *back = [[UIControl alloc] initWithFrame:[[UIScreen mainScreen]bounds]];
back.backgroundColor = [UIColor grayColor];
self.view = back;
[back release];
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
portrait = [[PortraitView alloc] initWithFrame:CGRectMake(10, 10, 300, 440)];
portrait.backgroundColor = [UIColor yellowColor];
[portrait addButton];
landscape = [[LandscapeView alloc] initWithFrame:CGRectMake(10, 10, 460, 280)];
landscape.backgroundColor = [UIColor greenColor];
[self.view addSubview:portrait];
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return YES;
}
分析:willAnimateRotationToInterfaceOrientation方法是用于横纵屏变化的时候的切换用。
portrait和landscape是两个视图。
0 0
- 【ios】 iphone开发之横屏与竖屏在不同视图之间的切换
- iphone开发之横屏与竖屏在不同视图之间的切换
- [IOS]iphone开发之横屏与竖屏在不同视图之间的切换
- iPhone开发之ModalViewController视图切换
- iPhone开发之几种视图切换
- iphone应用开发之 --视图之间的小发现.
- IPHONE开发 VIEW之间的相互切换
- Objective-C ,ios,iphone开发基础:多个视图(view)之间的切换,以及视图之间传值。使用parent <->dismiss
- Objective-C ,ios,iphone开发基础:多个视图(view)之间的切换2,使用导航栏控制,以及视图之间传值。
- iphone 开发 窗口(UIWindow) 与视图(UIView)之间以及整个程序间的关系,深层解析
- 怎样在MDI程序里面切换不同的 视图?
- iphone切换不同的环境
- iphone 旋转横屏与竖屏切换view
- iphone视图之间的过度
- iphone视图之间的过度
- iPhone使用委托在不同的窗口之间传递数据
- iPhone使用委托在不同的窗口之间传递数据
- .NET :在Visual Studio的不同Tab之间切换
- 关于TabHost切换的时候刷新(更新)页面的问题
- Windows7 x64系统下搭建 APACHE2.4.10+PHP5.5.19+ORACLE_11g 平台之PHP篇
- 动态代理
- 内涵图
- 黑马程序员------java高新技术、枚举
- iphone开发之横屏与竖屏在不同视图之间的切换
- SSD
- spring中动态代理的实现(annotation形式实现)
- 第十六周项目6-武功秘籍
- 完全素数
- Windows7 x64系统下搭建 APACHE2.4.10+PHP5.5.19+ORACLE_11g 平台之ORACLE篇
- 关于android系统app设计的个人观点
- Java的四中引用
- grep 搜索字符串命令