UIAlertView is crashing app on iOS 7

前端 未结 2 1204
别那么骄傲
别那么骄傲 2020-12-20 10:14

I have just released my app on the App Store however I have just been emailed and told that there is issues with crashing.

The issue is with Alert Views which crash

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-20 10:44

    I had the same problem in the relese build. It seems an internal bug of the swift compiler (using Xcode 6.0.1 (6A317) )

    I solved actually with a objC helper class with this method:

    + (BOOL) checkIfClassExists:(NSString *)className {
        id c = objc_getClass([className cStringUsingEncoding:NSASCIIStringEncoding]);
        if (c != nil) {
            return YES;
        } else {
            return NO;
        }
    }
    

    called in my swift code with a bridge header

    if ObjCFix.checkIfClassExists("UIAlertController") {
        //iOS 8 code here
    } else {
        //iOS 7 code here
    }
    

提交回复
热议问题