Categories
-
Recent Posts
Recent Comments
- admin on How to fix – There was an internal API error
- Jose on How to fix – There was an internal API error
- admin on 簡單學日語 2.0 上架了
- 中國青年救國團 on 簡單學日語 2.0 上架了
- admin on iOS Watchkit Development – paired device unavailable for development
Categories
-
Recent Posts
Recent Comments
- admin on How to fix – There was an internal API error
- Jose on How to fix – There was an internal API error
- admin on 簡單學日語 2.0 上架了
- 中國青年救國團 on 簡單學日語 2.0 上架了
- admin on iOS Watchkit Development – paired device unavailable for development
Daily Archives: 2015/05/21
UILabel 動態高度 Dynamic Height
UITableViewCell 有 heightForRowAtIndexPath 可以指定 但是實務上總是會碰到客戶的要求:「動態列高」 若是「想以文字內容決定 UILabel 的高度」 可以使用下面的程式 先用「文字,字型和寬度」(這點要事先決定,不然沒辦法算)計算出 UILabel 的高度 然後再用這個算出來的高度去 initWithFrame 搞定,收工放飯 +(float) getHeightForText:(NSString*) text withFont:(UIFont*) font andWidth:(float)width { CGSize constraint = CGSizeMake(width , 20000.0f); CGSize title_size; float totalHeight; SEL selector = @selector(boundingRectWithSize:options:attributes:context:); if ([text respondsToSelector:selector]) … Continue reading
Posted in iOS development
Leave a comment
不要再抓手機型號了,因為 iPhone6/6P 有 Zoom 果實能力
如果你會看到這篇文章 很有可能你是因為想判斷 iPhone 的不同型號 然後做不同的顯示(字體大小、間距….) 現在讓我告訴你 不要再這麼做了 因為東西南北有的沒有的原因 我落入了「判斷手機型號,然後寫不同的顯示 code」的地獄深淵 好不容易寫完了 交付使用者測試時卻發現「走鐘」現象 奇怪的是在模擬器上顯示一切正常 後來才知道 除了可以設定字體大小之外 iPhone 6/6P 還提供了 Zoom 的功能(註) (分成一般顯示和 Zoom 顯示) iPhone 6Plus 開啟 Zoom 模式,就等同 iPhone 6 的顯示方式 iPhone 6 開啟 Zoom 模式,就等同 iPhone 5S … Continue reading
Posted in iOS development
Leave a comment