UIButtonTypeSystem 没有在 iOS 6 中定义
如果我输入以下代码会使应用程序崩溃?
if(appSetting.iOSVersion>=7){
photo = [UIButton buttonWithType:UIButtonTypeSystem];
}else{
photo = [UIButton buttonWithType:UIButtonTypeRoundedRect];
}
如何编写代码来检查 UIButtonTypeSystem 是否已定义并防止崩溃?
最佳答案
如果您需要支持 iOS 6,请使用 UIButtonTypeRoundedRect 而不是 UIButtonTypeSystem。然后它将在 iOS 6 和 7 下工作。 在文档中它指出:
UIButtonTypeSystem A system style button, such as those shown in navigation bars and toolbars. Available in iOS 7.0 and later.
关于ios - 在代码中测试 UIButtonTypeSystem 是否为 iOS6 定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25784087/