zoukankan      html  css  js  c++  java
  • 弹出框适配总结

    1、屏幕旋转

    显示视图时,尽量不用单一的view去实现,将view放在viewcontroller里实现,这样可以在viewController中去添加其旋转方法,实现适配屏幕旋转。

    (1)支持全部方向的旋转

    iOS6.0需要下面三个方法,代码如下:

    -(BOOL) shouldAutorotateToInterfaceOrientation : (UIInterfaceOrientation) toInterfaceOrientation{

        return (toInterfaceOrientation != UIInterfaceOrientationMaskPortraitUpsideDown);

    }

    - (BOOL)shouldAutorotate{

        return YES;

    }

    - (NSUInteger)supportedInterfaceOrientations{

        return UIInterfaceOrientationMaskAllButUpsideDown;

    }

    (2)禁止屏幕旋转

    -  (BOOL) shouldAutorotateToInterfaceOrientation : (UIInterfaceOrientation) toInterfaceOrientation{

        return (toInterfaceOrientation == UIInterfaceOrientationPortrait);

    }

    - (BOOL)shouldAutorotate{

        return NO;

    }

    - (NSUInteger)supportedInterfaceOrientations{

        return UIInterfaceOrientationMaskPortrait;//只支持这一个方向(正常的方向)

    }

    2、屏幕旋转基本方法
    -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 
        NSLog(@"视图旋转之前自动调用"); 

    - (void) willAnimateRotationToInterfaceOrientation : (UIInterfaceOrientation) toInterfaceOrientation duration : (NSTimeInterval) duration { 
        NSLog(@"视图旋转方向发生改变时会自动调用"); 

    -(void) didRotateFromInterfaceOrientation : (UIInterfaceOrientation fromInterfaceOrientation{
        NSLog(@"视图旋转完成之后自动调用"); 

    -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
        NSLog(@"视图旋转之前自动调用");
    }
    -(void) willAnimateRotationToInterfaceOrientation : (UIInterfaceOrientation) toInterfaceOrientation duration : (NSTimeInterval)duration{
        NSLog(@"视图旋转方向发生改变时会自动调用");
    }

    -(void) didRotateFromInterfaceOrientation : (UIInterfaceOrientation) fromInterfaceOrientation{
        NSLog(@"视图旋转完成之后自动调用");
    }

    3、旋转后调整视图大小。

    当UIView设置成自动适配屏幕(即myView.autoresizesSubviews = YES)时,当我们重新设置myView的frame时(一般屏幕旋转时我们都会重新设置view的frame),会自动调用layoutSubviers方法,我们可以在该方法中判断屏幕的方向,并调整各子view的frame。

    而设置UIView的属性autoresizingMask,可以调节其在父视图的相对位置:

    UIViewAutoResizingFlexibleLeftMargin将调整view左侧到父视图的距离。

    UIViewAutoResizingFlexibleTopMargin将调整view上侧到父视图的距离。

    UIViewAutoResizingFlexibleWidth将调整view对应父视图的宽度。

    其他的类似。

  • 相关阅读:
    @@IDENTITY 存储过程
    ASP.NET的Cookie和Session
    数据格式设置表达式
    DataTable类(MSDN)
    用静态变量代替appliction
    C cgi url 编码解码问题
    C#视频头操作
    c#网页抓取
    c语言字符串分隔
    CGI c 上传文件
  • 原文地址:https://www.cnblogs.com/nanoCramer/p/3192793.html
Copyright © 2011-2022 走看看