iOS 竖屏和横屏的切换
来源:互联网 发布:天猫和淘宝哪个质量好 编辑:程序博客网 时间:2024/05/05 12:04
1.只支持一种方向,直接在工程 --- target — general 上直接设置某一个方向就行。
2.要是支持多个方向,在general上设置好支持的方向,然后单独写个基类,把需要转向的类继承这个基类就好,然后设置方向
.h
#import <UIKit/UIKit.h>
@interface CustomNavigationController : UINavigationController
@property(nonatomic)NSUInteger orientation;
.m
#import "CustomNavigationController.h"
@interface CustomNavigationController ()
@end
@implementation CustomNavigationController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations{
//return UIInterfaceOrientationMaskLandscapeRight;
return self.orietation;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != self.orietation);
}
@interface CustomNavigationController ()
@end
@implementation CustomNavigationController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations{
//return UIInterfaceOrientationMaskLandscapeRight;
return self.orietation;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != self.orietation);
}
来源:http://www.cocoachina.com/bbs/read.php?tid-244095-page-1.html
0 0
- iOS 竖屏和横屏的切换
- iOS的横竖屏切换
- iOS横屏、竖屏切换
- [iOS]关于iOS中界面视图横屏/竖屏切换的问题总结
- android模拟器的竖屏和横屏切换
- Android模拟器横屏和竖屏的切换
- 禁止横屏和竖屏的切换
- Android模拟器横屏和竖屏的切换
- Android模拟器横屏和竖屏的切换快捷方式
- iOS 横竖屏的切换以及个别界面横屏
- iOS中单个控制器横屏切换的研究
- ios横竖屏切换
- IOS横竖屏切换
- IOS 横竖屏切换
- iOS横竖屏切换
- ios 切换横竖屏
- iOS 横竖屏切换
- iOS 横竖屏切换
- 加密文件系统eCrypt概述
- 关于Tomcat单独运行和在eclipse下运行时路径的问题
- 操作系统--处理调度与死锁
- 记录下python的无名管道半双工通信
- 网络爬虫的实现
- iOS 竖屏和横屏的切换
- 10大常见的安全漏洞!你知道吗?
- wap站获取上网用户手机型号的方法 .net的写法
- 使用 lodop的web套打程序开发
- web经典问题-清浮动-事件冒泡
- Java多线程之wait()、notify()、notifyAll()
- 大话设计模式-模板方法模式
- spoj BCEASY - Bottom Coder (Easy)
- ORA-00837: Specified value of MEMORY_TARGET greater than MEMORY_MAX_TARGET