首页 > 其他 > 详细

关于iphone和ipad横屏竖屏 适配问题

时间:2015-05-12 13:15:04      阅读:222      评论:0      收藏:0      [点我收藏+]

首先 先在viewWillAppear 里面 注册通知

- (void)viewWillAppear:(BOOL)animated

{

    [super viewWillAppear:animated];

    //注册屏幕旋转 消息通知

    [[NSNotificationCenter defaultCenter] addObserver:self

                                             selector:@selector(changeFrames:)

                                                 name:UIDeviceOrientationDidChangeNotification

                                               object:nil];

    }

viewDidLoad 初始化控件 

收到通知后

//收到通知后改变view坐标

-(void)changeFrames:(NSNotification *)notification

{

    CGRect rect = [UIScreen mainScreen].bounds;

    

    if ([[UIDevice currentDevice] orientation]==UIInterfaceOrientationPortrait

        || [[UIDevice currentDevice] orientation]==UIInterfaceOrientationPortraitUpsideDown)

    {

        NSLog(@"portrait");

        _fancyTabBar.frame=CGRectMake(rect.size.width-300,rect.size.height-300, 300, 300);

    }

    else

    {

        NSLog(@"横屏");

        _fancyTabBar.frame=CGRectMake(rect.size.height-40,rect.size.width-550, 300, 300);

    }

}

如果是ipad 版

//收到通知后改变view坐标

-(void)changeFrames:(NSNotification *)notification

{

    CGRect rect = [UIScreen mainScreen].bounds;

    

    if ([[UIDevice currentDevice] orientation]==UIInterfaceOrientationPortrait)

    {

        NSLog(@"竖屏home在下");

        _fancyTabBar.frame=CGRectMake(rect.size.width-550,rect.size.height-550, 600, 700);

    }

    else if ([[UIDevice currentDevice] orientation]==UIInterfaceOrientationPortraitUpsideDown)

    {

        NSLog(@"竖屏home在下");

        _fancyTabBar.frame=CGRectMake(rect.size.width-550,rect.size.height-550, 600, 700);

        

    } else if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft ){

        

        NSLog(@"横屏home在左");

        _fancyTabBar.frame=CGRectMake(rect.size.height-300,rect.size.width-800, 600, 600);

 

        

    } else{

        

        NSLog(@"横屏home在右");

        _fancyTabBar.frame=CGRectMake(rect.size.height-300,rect.size.width-800, 600, 600);

    }

    

}

 

关于iphone和ipad横屏竖屏 适配问题

原文:http://www.cnblogs.com/panfeng1104/p/4496974.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!