ios - setTitleTextAttributes not working properly -
hello in i've been facing weird bug app works on iphone 6.
so in 1 of methods have
- (void)dummy { uifont *titlefont = [htfont thinfontofsize:20]; [[uinavigationbar appearance] settitletextattributes:@{ nsfontattributename:titlefont }]; } if comment out, app works on iphone 4s
i assuming wrong htfont file can't seem figure out.
htfont.m
#define is_ipad (ui_user_interface_idiom() == uiuserinterfaceidiompad) #define is_iphone (ui_user_interface_idiom() == uiuserinterfaceidiomphone) #define screen_width cgrectgetwidth([[uiscreen mainscreen] bounds]) #define screen_height cgrectgetheight([[uiscreen mainscreen] bounds]) #define is_iphone4 (is_iphone && max(screen_width, screen_height) < 568.0) #define is_iphone5 (is_iphone && max(screen_width, screen_height) == 568.0) #define is_iphone6 (is_iphone && max(screen_width, screen_height) == 667.0) #define is_iphone6p (is_iphone && max(screen_width, screen_height) == 736.0) static nsstring * const kfontname = @"sourcesanspro-regular"; static nsstring * const kthinname = @"sourcesanspro-light"; @implementation htfont + (uifont *)fontofsize:(cgfloat)size { return [uifont fontwithname:kfontname size:[htfont adjustedfontsizeforscreen:size]]; } + (uifont *)thinfontofsize:(cgfloat)size { return [uifont fontwithname:kthinname size:[htfont adjustedfontsizeforscreen:size]]; } + (cgfloat)adjustedfontsizeforscreen:(cgfloat)size { if (is_iphone5) { return size; } else if (is_iphone6) { return size * 1.1; } else if (is_iphone6p) { return size * 1.2; } else { return size * 0.9; } } what causing error?
*** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '*** -[__nsplaceholderdictionary initwithobjects:forkeys:count:]: attempt insert nil object objects[1]' *** first throw call stack:
Comments
Post a Comment