现在的位置: 首页 > 综合 > 正文

防止ios6下中文输入时,锁屏lock screen导致crash

2018年01月28日 ⁄ 综合 ⁄ 共 588字 ⁄ 字号 评论关闭
在AppDelegate.m中加入如下代码即可。
- (void)applicationDidEnterBackground:(UIApplication *)application
{    
    if (kCFCoreFoundationVersionNumber > kCFCoreFoundationVersionNumber_iOS_5_1)
    {
        // Acquired additional time
        UIDevice *device = [UIDevice currentDevice];
        BOOL backgroundSupported = NO;
        if ([device respondsToSelector:@selector(isMultitaskingSupported)]) {
            backgroundSupported = device.multitaskingSupported;
        }
        
        if (backgroundSupported) {
            __block UIBackgroundTaskIdentifier backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{
                [application endBackgroundTask:backgroundTask];
                backgroundTask = UIBackgroundTaskInvalid;
            }];
        }
        
    }
}

抱歉!评论已关闭.