zoukankan      html  css  js  c++  java
  • 用通知解决由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);

    }

    }

  • 相关阅读:
    耗油
    [深入Python]Alex Martelli的Borg类
    Python Frame objects 和Traceback objects
    2012美国汽车销量排行
    Python中统计函数的运行耗时
    Python显示函数的调用者
    Python的内置函数map
    [深入Python]简单事情复杂化:Python计算阶乘
    Solaris查看线程
    VVR常用操作
  • 原文地址:https://www.cnblogs.com/xcy617/p/2875087.html
Copyright © 2011-2022 走看看