VIDEO_TOO_LONG_TITLE alert shown by UIImagePickerController

微笑、不失礼 提交于 2019-12-01 14:31:11

问题


I use a UIImagePickerController to take movies. The length of a movie is limited by setting the videoMaximumDuration property of the controller.
When one tries to take a longer movie, an alert is shown, as expected.

However an unexpected additional alert entitled VIDEO_TOO_LONG_TITLE is shown directly above the controls (see image below).
Apparently this is an iOS bug (only partly localized, no clip has been selected).

Is it possible to hide this unnecessary and inappropriate alert?


回答1:


imagePicker.allowsEditing = false



回答2:


I know the question is quite old, but here's a solution to the problem that is still not addressed by Apple.

@implementation NSBundle (UIImagePickerControllerLocalizationFix)

+ (void) load {
    SEL const selector = @selector (localizedStringForKey:value:table:);
    Method const localizedStringMethod = class_getInstanceMethod (self, selector);
    NSString *(*originalImp) (NSBundle *, SEL, NSString *, NSString *, NSString *) = (typeof (originalImp)) method_getImplementation (localizedStringMethod);
    IMP const updatedImp = (typeof (updatedImp)) imp_implementationWithBlock (^(NSBundle *bundle, NSString *key, NSString *value, NSString *tableName) {
        NSString *const result = originalImp (bundle, selector, key, value, tableName);
        if ([key isEqualToString:@"VIDEO_TOO_LONG_TITLE"] && [result isEqualToString:key]) {
            static NSBundle *properLocalizationBundle = nil;
            static NSString *properLocalizationTable = nil;
            static dispatch_once_t onceToken;
            dispatch_once (&onceToken, ^{
                NSString *const originalBundleName = bundle.infoDictionary [(NSString *) kCFBundleNameKey];
                NSArray <NSBundle *> *const frameworkBundles = [NSBundle allFrameworks];
                for (NSBundle *frameworkBundle in frameworkBundles) {
                    NSString *const possibleTableName = [originalBundleName isEqualToString:tableName] ? frameworkBundle.infoDictionary [(NSString *) kCFBundleNameKey] : tableName;
                    NSString *const localizedKey = originalImp (frameworkBundle, selector, key, value, possibleTableName);
                    if (![localizedKey isEqualToString:key]) {
                        properLocalizationBundle = frameworkBundle;
                        properLocalizationTable = possibleTableName;
                        break;
                    }
                }

                if (!(properLocalizationBundle && properLocalizationTable)) { // Giving up
                    properLocalizationBundle = bundle;
                    properLocalizationTable = tableName;
                }
            });

            return originalImp (properLocalizationBundle, selector, key, value, properLocalizationTable);
        } else {
            return result;
        }
    });
    method_setImplementation (localizedStringMethod, updatedImp);
}

@end


来源:https://stackoverflow.com/questions/40317259/video-too-long-title-alert-shown-by-uiimagepickercontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!