iOSiOS开发代码段程序员

【TIP】兼容iOS7的几个坑

2014-12-24  本文已影响3708人  千煌89

1、baseline

2、[[UINavigationBar appearance] setTranslucent:NO]

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** Illegal property type, c for appearance setter, _installAppearanceSwizzlesForSetter:'
if(IOS8_OR_LATER && [UINavigationBar conformsToProtocol:@protocol(UIAppearanceContainer)]) {
        [[UINavigationBar appearance] setTranslucent:NO];
    }

3、storyboard segue show

iOS7下变成从底部推出的,而且没有navigation

4、constrain to margin

5、 imageFromBundle
在iOS8下,下面这段代码是没有问题的。

+ (UIImage *)imagesNamed:(NSString *)name fromBundle:(NSString *)bundleName
{
    NSString *main_images_dir_path = [[[NSBundle mainBundle] resourcePath] stringByAppendingFormat:@"/%@.bundle",bundleName];
    NSString *image_path = [main_images_dir_path stringByAppendingPathComponent:name];
    return [UIImage imageWithContentsOfFile:image_path];
}

而在iOS7下,返回的UIImage是nil。原因是在iOS7下,必须要加上.png或者@2x.png,否则[UIImage imageWithContentsOfFile:image_path]是无法争取找到文件路径的。

上一篇 下一篇

猜你喜欢

热点阅读