码迷,mamicode.com
首页 > 其他好文 > 详细

模拟器使用

时间:2015-12-27 17:49:51      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

模拟器调节大小:打开模拟器,window->scale->选择大小

测模拟器的方向

打开空白项目,打开ViewController.m文件,编写代码检测模拟器的方向:

- (void)viewDidLoad {
    [super viewDidLoad];
    //检测模拟器方向的切换,NSNotificationCenter捕获消息通讯
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(orientationChanged) //处理方向切换事件的方法
                                                 name:UIDeviceOrientationDidChangeNotification
                                               object:nil];
}
//处理方向切换事件的方法
-(void) orientationChanged
{
    switch ([[UIDevice currentDevice] orientation]) {
        case UIDeviceOrientationPortrait: //屏幕直立
            NSLog(@">>>>>>>>>>>>>>>>>>>屏幕直立UIDeviceOrientationPortrait");
            break;
        case UIDeviceOrientationPortraitUpsideDown: //屏幕直立,上下颠倒
            NSLog(@">>>>>>>>>>>>>>>>>>>屏幕直立,上下颠倒UIDeviceOrientationPortraitUpsideDown");
            break;
        case UIDeviceOrientationLandscapeLeft: //屏幕横向且屏幕向左
            NSLog(@">>>>>>>>>>>>>>>>>>>屏幕横向且屏幕向左UIDeviceOrientationLandscapeLeft");
            break;
        case UIDeviceOrientationLandscapeRight: //屏幕横向且屏幕向右
            NSLog(@">>>>>>>>>>>>>>>>>>>屏幕横向且屏幕向右UIDeviceOrientationLandscapeRight");
            break;
        case UIDeviceOrientationFaceDown: //屏幕面朝下
            NSLog(@">>>>>>>>>>>>>>>>>>>屏幕面朝下UIDeviceOrientationFaceDown");
            break;
        case UIDeviceOrientationFaceUp: //屏幕面朝上
            NSLog(@">>>>>>>>>>>>>>>>>>>屏幕面朝上UIDeviceOrientationFaceUp");
            break;
        default:
            break;
    }
}

运行项目,打开模拟器,点击HardWare->Rotate Left 硬件->向左旋转屏幕,查看打印的日志:

2015-12-27 17:01:28.450 DemoApp[1387:35944] >>>>>>>>>>>>>>>>>>>屏幕横向且屏幕向右UIDeviceOrientationLandscapeRight
2015-12-27 17:01:58.030 DemoApp[1387:35944] >>>>>>>>>>>>>>>>>>>屏幕直立UIDeviceOrientationPortrait
2015-12-27 17:02:08.076 DemoApp[1387:35944] >>>>>>>>>>>>>>>>>>>屏幕横向且屏幕向左UIDeviceOrientationLandscapeLeft
2015-12-27 17:02:19.566 DemoApp[1387:35944] >>>>>>>>>>>>>>>>>>>屏幕直立,上下颠倒UIDeviceOrientationPortraitUpsideDown
2015-12-27 17:02:25.502 DemoApp[1387:35944] >>>>>>>>>>>>>>>>>>>屏幕横向且屏幕向右UIDeviceOrientationLandscapeRight
2015-12-27 17:02:32.699 DemoApp[1387:35944] >>>>>>>>>>>>>>>>>>>屏幕直立UIDeviceOrientationPortrait
2015-12-27 17:02:37.586 DemoApp[1387:35944] >>>>>>>>>>>>>>>>>>>屏幕横向且屏幕向左UIDeviceOrientationLandscapeLeft

 

模拟器使用

标签:

原文地址:http://www.cnblogs.com/for-you/p/5080398.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!