Monday, January 23, 2012

UILabel/UIButton not showing text - iPhone 4

If the text is showing perfectly fine in other devices, first thing I would check is the font assigned. There is a small issue with the new Xcode version (version 4.2). Some of the fonts you get in the IB (Interface Builder) are not available in all iOS versions and devices. For example the font "Helvetica Neue Medium" is not available in iPhone 4 running iOS 4.3.5

The same problem (UILabel/UIButton not showing text) happened to me because of this font issue. Changing "Medium" to "Regular" was my fix. If you are looking for a font list, you can get it by executing following code.

Objective C

for( NSString *familyName in [UIFont familyNames] ) {
for( NSString *fontName in [UIFont fontNamesForFamilyName:familyName] ) {
NSLog(@"%@", fontName);
}
}

Swift

for familyName in UIFont.familyNames(){
print(familyName)
}

4 comments:

Anonymous said...

thanks a lot for your post. It fixed the problem which puzzled me for some time. glad I came across this post.

Ramesh Arangot said...

Hi Yaar ,,,,,


Thanks a lot .... It saved my time.

Some thing by Mahmood Memon said...

Thanks Buddy.

Anonymous said...

you can add fonts which are not available by default as mentioned here.