简体   繁体   中英

Button Images Don't Show When Using Xcode 5

I have several buttons with images assigned to each. In Xcode 4.6 using the iOS 6 SDK, they show like they should. When using Xcode 5 with the iOS 7 SDK, the images are not there. In the xib it says an image is on the button but it doesn't appear. Any ideas why?

iOS 6: 在此处输入图片说明

iOS 7: 在此处输入图片说明

For me, my problem was that the button type was set to System instead of Custom. They displayed fine in iOS 6.0 and iOS 6.1 Simulators, just not iOS 7.0 simulator. I'm not sure how this happened as I'm pretty sure it's the first time the project had been opened in Xcode 5 with iOS 7.0 sdk. I had three buttons, 1 showed fine because it was a Custom button, and the other two did not show their images, but could be pressed. Once set to Custom button types, all worked great, as expected.

I was able to get the images to appear after setting the tint color to clear and setting the image and background image to what I wanted. In Xcode 4 I didn't have to change any of that and I didn't have to set the background image, just the image.

yes it is iOS7 issue.

Set bottom margin of the image/label through autolayout then try this code in your viewDidLoad and this should work.

if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)])
{
    [self prefersStatusBarHidden];
    [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
}
else
{
    // iOS 6
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM