UIButton's title disappears
I added buttons to xib as normal using iOS 6 SDK and Xcode 4.5.
When I run the app on iOS 6 simulator, there is no problem. But when I run it on the iOS 5.x simulator (or device), the title on the button always disappears(not every time). Lots of my view controllers have this problem.
PS: Only Custom type button have this problem
Found the reason:
[[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setTitle:@"取消" forState:UIControlStateNormal]
Did you set the font title as Attributed
which is not working with iOS 5 & iOS 5.1 ? change it to Plain
, now it should work fine with all versions.
EDIT
when you select the button in your xib
your attribute inspector
should look like this:
Make sure you are putting image in Background
and not in Image
(see image below)
Also check if you are adding title using code, then [button setTitle:title forState:state];
should be there.
下一篇: UIButton的标题消失