乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      IOS適配屏幕

       plumbiossom 2014-07-25

      一、旋轉(zhuǎn)處理
          第一步:注冊通知 [[NSNotificationCenter defaultCenter] addObserver:self
                                                           selector:@selector(changeFrames:)                                                     
                                  name:UIDeviceOrientationDidChangeNotification
                                                             object:nil];
          第二把:處理接收事件
      -(void)changeFrames:(NSNotification *)notification{
          NSLog(@"change notification: %@", notification.userInfo);
          float width=[[UIScreen mainScreen]bounds].size.width*[[UIScreen mainScreen] scale];
          float height=[[UIScreen mainScreen]bounds].size.height*[[UIScreen mainScreen] scale];
          if ([[UIDevice currentDevice] orientation]==UIInterfaceOrientationPortrait
              || [[UIDevice currentDevice] orientation]==UIInterfaceOrientationPortraitUpsideDown) {
              NSLog(@">>>portrait");
              self.frame=CGRectMake(0, 0, height, width);
          }else{
              NSLog(@">>>landscape");
              self.frame=CGRectMake(0, 0, width, height);
          }
          
          NSLog(@"view—> %@",self);
      }

      二、獲取屏幕分辨率
          //得到當(dāng)前屏幕的尺寸:
          CGSize size_screen = [[UIScreenmainScreen]bounds].size;
          //獲得縮放率:
          CGFloat scale_screen = [UIScreen mainScreen].scale;   

          此時屏幕尺寸的寬高與scale的乘積就是相應(yīng)的分辨率值。
          CGRect sizeOfA4 = CGRectMake(0, 0, 595, 842);//生成PDF文件時按A4標(biāo)準(zhǔn)
          CGRect sizeOfA5 = CGRectMake(0, 0, 421, 595);//生成PDF文件時按A5標(biāo)準(zhǔn)
          注意:不管scale=1還是scale=2,紙張的標(biāo)準(zhǔn)sizeOfA4和sizeOfA5的設(shè)置都不變,這是因?yàn)槲覀兺ǔTO(shè)置的寬高在iOS體系下都是邏輯上的point,并不是真實(shí)的像素!
      只要屏幕是等比例放大縮小,[[UIScreenmainScreen]bounds].size都不變。不同scale的系統(tǒng)會自動放大或縮小,這就是所有的應(yīng)用在320x480和640x960環(huán)境下無差別運(yùn)行的原因。

      三、設(shè)備標(biāo)準(zhǔn)
          iPhone/iPod Touch (320點(diǎn) x 480點(diǎn))
          普屏分辨率    320像素 x 480像素
          Retina分辨率 640像素 x 960像素

          iPad,iPad2/New iPad (768點(diǎn) x 1024點(diǎn))
          普屏        768像素 x 1024像素
          Retina屏  1536像素 x 2048像素

          換算關(guān)系 (在 iPhone3 上 1個 Point 相當(dāng)于 1個pixel ; 而 iPhone4 上1個 point 就相當(dāng)于4個 pixel;)
          普屏       1點(diǎn) = 1像素   image.png
          Retina屏   1點(diǎn) = 2像素   image@2x.png  


      四、 真機(jī)與模擬器判斷+設(shè)備類型判斷
          #if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR
              NSLog(@" on simulator");
          #else
              NSLog(@"not on simulator");
          #endif
          注意:TARGET_OS_IPHONE在真機(jī)和模擬器上都是1
          設(shè)備類型判斷方法有兩種:
          1. UI_USER_INTERFACE_IDIOM() 進(jìn)行區(qū)分(ios 3.2以上),但是無法區(qū)分iphone和ipod
              if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
                  //設(shè)備為ipad
              } else {
                  //設(shè)備為iphone 或 ipod
              }
          2. 使用 UIDevice.model 進(jìn)行區(qū)分  (ios 2.0 >=)
              NSString *deviceType = [UIDevice currentDevice].model;    
              if([deviceType isEqualToString:@"iPhone"]) {
                    //iPhone
              }else if([deviceType isEqualToString:@"iPod touch"]) {
                  //iPod Touch
              }else {
                  //iPad
              }


      五、獲取設(shè)備相關(guān)信息
          //軟件信息
          NSLog(@"sysname=%@",[[UIDevice currentDevice] systemName]);// 系統(tǒng)名
          NSLog(@"systemVersion=%@",[[UIDevice currentDevice] systemVersion]); //版本號
          NSLog(@"model=%@",[[UIDevice currentDevice] model]); //類型(ipad、ipod、iphone)而[[UIDevice currentDevice] userInterfaceIdiom]只能判斷iphone和ipad
          NSLog(@"olduuid=%@",[[UIDevice currentDevice] uniqueIdentifier]); //唯一識別碼 ios5.0開始deprecated
          NSLog(@"name=%@",[[UIDevice currentDevice] name]); //設(shè)備名稱
          NSLog(@"localizedModel=%@",[[UIDevice currentDevice] localizedModel]); // 本地模式
          NSLog(@"ios6UUID=%@",[[[UIDevice currentDevice] identifierForVendor] UUIDString]);//ios6.0開始available
         
         注:以下內(nèi)容未測試,
          // 硬件信息
          [UIDevice platform];//平臺
          [UIDevice cpuFrequency]];//cpu信息
          UIDevice busFrequency]];//總線
          [UIDevice totalMemory]];//總內(nèi)存
          UIDevice userMemory]];//已經(jīng)使用的內(nèi)存
          -----------------------------------------------------------------------------------------------------------------------------
          //App信息
          NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
          CFShow(infoDictionary);//所有plist內(nèi)容
          // app名稱
          NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
          // app版本
          NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
          // app build版本
          NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"];

          判斷是否有照相機(jī)
          if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
              NSLog(@"有");
          else
              NSLog(@"沒有");

      六、針對不同分辨率的設(shè)備,程序員只需要做三件事:
          1.提供app高清圖標(biāo);
          2.UI圖片素材@2x.png;
          3.從網(wǎng)絡(luò)下載適配的圖片(判斷條件[[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2)
          -所有的iPhone、iPod Touch設(shè)備的 Point分辨率都是 320×480,也就是邏輯分辨率都一致,保證了App不需要修改也能正常的在高像素分辨率上運(yùn)行,只是原來App中的圖片會被拉升后顯示,影響美觀,沒有發(fā)揮retina的優(yōu)勢。
          -程序內(nèi)所有的GCRectMake都是邏輯分辨率,不影響位置和大?。∽鲇螒蜷_發(fā)最有用,普通app影響不大
          -問題:如何進(jìn)行相對布局???(6.0之前有autoResizeMask,autoresizing    6.0可使用與android相對布局類似的autoLayout)

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多