2014年10月24日 星期五

[iOS] How to detect iPhone 6 Plus screen size

簡單列出一下 iPhone 6 & iPhone 6 Plus 解析度:
        iPhone 6(4.7"):   750w x 1334h @2x (in points: 375w x 667h)
iPhone 6 Plus(5.5"): 1242w x 2208h @3x (in points: 414w x 736h)

本來天真的以為要判斷是否為 iPhone 6 Plus 只要查看 w or h 即可,但發現用模擬器執行 NSLog 印出 [UIScreen mainScreen].bounds 發現竟然跟 iPhone 5(4") 的解析度相同為 640w x 1136h,代誌不是憨人所想的那樣,查了一下發現可以用 nativeScale 來判斷,程式碼如下所示:

- (BOOL)IsiPhone6Plus
{
    if([[UIScreen mainScreen] respondsToSelector:@selector(nativeScale)])
    {
        // Nativescale is always 3 for iPhone 6 Plus
        if([UIScreen mainScreen].nativeScale > 2.1)
            return YES;
    }

    return NO;
}

Reference: http://stackoverflow.com/questions/25756087/detecting-iphone-6-6-screen-sizes-in-point-values

2014年10月20日 星期一

[iOS] iOS 8 UIAlertController scrolling 小記

最近發現在 UIAlertController 的 message 如果太長會導致無法 scroll ,解決方法為設定 frame 即可。如下:

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Title"
                                                                         message:messageString
                                                                  preferredStyle:UIAlertControllerStyleAlert];

alertController.view.frame = [[UIScreen mainScreen] applicationFrame];

Reference : http://stackoverflow.com/questions/24671833/uialertcontroller-uialertview-scrolling-on-ios-8

2014年10月5日 星期日

[iOS] iOS 6/7/8 UIActivity subclass for Line App

GitHub 開張啦,獻上一個 support iOS 6/7/8 UIActivity subclass for Line App,連結如下:

LineActivity

[iOS] iOS 8 non-public API usage 解決方法 (持續更新...)

一直以來都知道 apple 會把使用 non-public API 的 app 給 reject,沒想到最近真的遇到了!

一開始 apple 很貼心給個指令供查詢,最近更新到使用 Application Loader 時就會提示 (佛心),免除到進入 in review 才被 reject 的痛苦!

這邊要記錄一下有 "不小心" 用到的 non-public API 列表:
NSURLRequest
+ (void)setAllowsAnyHTTPSCertificate:(BOOL)inAllow forHost:(NSString *)inHost;
用途:允許任何 cer 通過 https 的連線方式,可以改用 (AFNetworking) allowsInvalidSSLCertificate 設為 YES 即可。