yebw
yebw

Reputation: 247

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.

enter image description here

PS: Only Custom type button have this problem

enter image description here

Found the reason:
[[UIButton appearanceWhenContainedIn:[UISearchBar class], nil] setTitle:@"取消" forState:UIControlStateNormal]

Upvotes: 1

Views: 902

Answers (2)

Vaibhav Saran
Vaibhav Saran

Reputation: 12908

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.

enter image description here

Upvotes: 0

Ushan87
Ushan87

Reputation: 1623

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: enter image description here

Upvotes: 0

Related Questions