• 用通知解决由iphone 4到iphone 5由于屏幕变大带来的问题


    由iphone 4到iphone 5屏幕增大,会导致之前的应用出现两条黑边。我的应用是给黑边加两张图片进行遮盖。操作方法:

    1.在appdelegate中判断是否是iphone5 设备。如果是,加两个window,用以存放图片。

    if(iphone 5)

    {

     nsstring *path = [[nsbundle mainbundle]pathforresource:@"zuobian" oftype:@"png"];

    uiiamge *image = [uiimage imagewithcontentsoffile:path];//获取图片

    uiimageview *view = [[uiimageview alloc]initwithimage:image];

    uiwindow *window1 = [[uiwindow alloc]initwithframe:(cgrect){{0,0},{320,44}}];

    [window1 addsubview:view];

    window1.windowlevel = 3;

    [window1 makekeyandvisible];

    同理加上window2(rect为{0,524});

    }

    2.在应用的入口加上通知:

    if(iphone 5)

    {

     [[nsnotificationcenter defaultcenter]addobserver:self selector(changeNum) name:uideviceOrientationIsLandscape(90) object:nil];

    }

    -(void)changeNum

    {

     UIInterfaceOrientation orientation = self.interfaceOrientation;

    if(orientation == UIInterfaceOrientationLandscapeLeft && [PublicVarible singleInstance].Is_Iphone5 == NO)   //publicVarible为一个判断iphone5的单例{

          uiwindow *left =  [[uiapplication shareapplication].keyWindow];

          left.frame = cgrectmake(0,-44,320,568);

    }

    else if(*********right && *****)

    {

         **********

         right.frame = cgrectmake(0,44,320,568);

    }

    }

  • 相关阅读:
    linux整理
    C++ 11 多线程--线程管理
    VS2013 配置全局 VC++目录
    visual studio运行时库MT、MTd、MD、MDd的研究
    C++(vs)多线程调试 (转)
    VS工程和Qt工程转换
    Qt 读写XML文件
    win32开发中多字节(ANSI)和宽字符(UNICODE)字符串处理函数参考
    QMenu----QT鼠标右键弹出菜单
    C++ 单例模式析构函数的运用,析构函数的线程安全
  • 原文地址:https://www.cnblogs.com/xcy617/p/2875087.html
Copyright © 2020-2023  润新知