天天看點

IOS開發基礎知識--碎片7

三十八:各個版本IPHONE分辨率及圖檔的實作原理

desert@2x : iPhone 4s (320 x 420)
desert-568h@2x : iPhones 5, 5C and 5S (320 x 568)
desert-667h@2x : iPhone 6 (375 x 667)
desert-736h@3x : iPhone 6+ (414 x 736)
desert@2x~ipad : iPad (1024 x 768)


      

iPhone 4S  Screen Size: 3.5 Inches  Resolution: 640 x 960 (Half: 320 x 480)

iPhone 5  Screen Size: 4.0 Inches  Resolution: 640 × 1136 (Half: 320 x 568)

iPhone 5S/5C  Screen Size: 4.0 Inches  Resolution: 640 x 1136 (Half: 320 x 568)

iPhone 6  Screen Size: 4.7 Inches Resolution: 750 x 1334 (Half: 375 x 667)

iPhone 6 Plus  Screen Size: 5.5 Inches Resolution: 1242 x 2208 (1/3: 414 x 736)  The size of iPhone 6 Plus is @3x scaling. So, it is divided by 3.

IOS開發基礎知識--碎片7

界面大小比例:

IOS開發基礎知識--碎片7

圖檔大小實作的原理:

#import <UIKit/UIKit.h>

typedef NS_ENUM(NSInteger, thisDeviceClass) {

    thisDeviceClass_iPhone,
    thisDeviceClass_iPhoneRetina,
    thisDeviceClass_iPhone5,
    thisDeviceClass_iPhone6,
    thisDeviceClass_iPhone6plus,

    // we can add new devices when we become aware of them

    thisDeviceClass_iPad,
    thisDeviceClass_iPadRetina,


    thisDeviceClass_unknown
};

thisDeviceClass currentDeviceClass();

@interface UIImage (DeviceSpecificMedia)

+ (instancetype )imageForDeviceWithName:(NSString *)fileName;

@end      
#import "UIImage+DeviceSpecificMedia.h"

thisDeviceClass currentDeviceClass() {

    CGFloat greaterPixelDimension = (CGFloat) fmaxf(((float)[[UIScreen mainScreen]bounds].size.height),
                                                    ((float)[[UIScreen mainScreen]bounds].size.width));

    switch ((NSInteger)greaterPixelDimension) {
        case 480:
            return (( [[UIScreen mainScreen]scale] > 1.0) ? thisDeviceClass_iPhoneRetina : thisDeviceClass_iPhone );
            break;
        case 568:
            return thisDeviceClass_iPhone5;
            break;
        case 667:
            return thisDeviceClass_iPhone6;
            break;
        case 736:
            return thisDeviceClass_iPhone6plus;
            break;
        case 1024:
            return (( [[UIScreen mainScreen]scale] > 1.0) ? thisDeviceClass_iPadRetina : thisDeviceClass_iPad );
            break;
        default:
            return thisDeviceClass_unknown;
            break;
    }
}

@implementation UIImage (deviceSpecificMedia)

+ (NSString *)magicSuffixForDevice
{
    switch (currentDeviceClass()) {
        case thisDeviceClass_iPhone:
            return @"";
            break;
        case thisDeviceClass_iPhoneRetina:
            return @"@2x";
            break;
        case thisDeviceClass_iPhone5:
            return @"-568h@2x";
            break;
        case thisDeviceClass_iPhone6:
            return @"-667h@2x"; //or some other arbitrary string..
            break;
        case thisDeviceClass_iPhone6plus:
            return @"-736h@3x";
            break;

        case thisDeviceClass_iPad:
            return @"~ipad";
            break;
        case thisDeviceClass_iPadRetina:
            return @"~ipad@2x";
            break;

        case thisDeviceClass_unknown:
        default:
            return @"";
            break;
    }
}

+ (instancetype )imageForDeviceWithName:(NSString *)fileName
{
    UIImage *result = nil;
    NSString *nameWithSuffix = [fileName stringByAppendingString:[UIImage magicSuffixForDevice]];

    result = [UIImage imageNamed:nameWithSuffix];
    if (!result) {
        result = [UIImage imageNamed:fileName];
    }
    return result;
}

@end      

三十九:其它幾張知識圖檔

1:NSObject繼承類圖

IOS開發基礎知識--碎片7

2:sqlite3傳回含義

IOS開發基礎知識--碎片7

3:視圖坐标說明

IOS開發基礎知識--碎片7

4:生命周期圖

IOS開發基礎知識--碎片7

5:UI繼承圖

IOS開發基礎知識--碎片7

6:Segue清單跳轉,關于selection跟Accessory的差別

IOS開發基礎知識--碎片7

7:IOS6與IOS7界頁的差别

IOS開發基礎知識--碎片7

四十:為什麼XCode項目中會有A M這種辨別

IOS開發基礎知識--碎片7

如果沒裝過svn,預設是本機 git管理。 M是表示改檔案有改動,A是新增加的檔案。目前是都沒有送出到伺服器狀态,到source control 裡點選commit 送出後就沒這些了,下次再有改動或新增,還會出現該标記。

四十一:MAC 本地進行IP映射域名的操作

1.打開finder, 快捷鍵:shift+command+g 前往檔案夾 “/etc” 

2.找到hosts檔案托到桌面修改,再把/etc下源檔案删除,把桌面修改好的拖進/etc。 

最後在終端:ping svnserver ,如果能ping通到192.168.1.51,說明映射成功 

四十二:arm64 armv7 armv7s arm6

目前ios的指令集有以下幾種:
• armv6 ◦ 
  iPhone
◦ iPhone2
◦ iPhone3G
◦ 第一代和第二代iPod Touch

• armv7
◦ iPhone4
◦ iPhone4S

• armv7s 
◦ iPhone5
◦ iPhone5C

• arm64 
◦ iPhone5S


 機器對指令集的支援是向下相容的,是以armv7的指令集是可以運作在iphone5S的,隻是效率沒那麼高而已~

================================================

Architecture : 指你想支援的指令集。

Valid architectures : 指即将編譯的指令集。

Build Active Architecture Only : 隻是否隻編譯目前适用的指令集。

================================================

 現在是2014年初,其實4和4S的使用者還是蠻多的,而iphone3之類的機器幾乎沒有了,是以我們的指令集最低必須基于armv7.

是以,Architecture的值選擇:armv7 armv7s arm64

PS:選arm64時需要最低支援5.1.1:      

 四十三:真機測試報 TCWeiboSDK 93 duplicate symbols for architecture armv7

這是因為在項目中引用的兩個相同的類庫引起了,在我的項目中是因為引入的兩個不同指令集引起的;

四十四:UINavigationBar的一些屬性的行為發生了變化

IOS開發基礎知識--碎片7
self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
self.navigationController.navigationBar.translucent = NO;      
iOS