iOS11 HTML Select Input Issue

HTML Select Input Dropdown is not getting dismissed properly on iOS 11 beta 5. Upon closing the dropdown, an empty dropdown with blank options reappears in its place.


Note: This issue was resolved in beta 4 but seems to have resurfaced in beta 5


Kindly let me know if this is a known issue and will be fixed in future beta releases or if a workaround is available.

Replies

Hey I just now found workaround.

Please build the ipa using xcode 8.If we build ipa using xcode 8 its working fine in iOS11.

i'm facing same issue now i'm using ios11 final version and also xcode 9 final version.


Any recommendation ?


Should i return to xcode 8 and install simulatator for ios 11 ?

Hello,


Also not working for my side using ios 11.0 and xcode 9

Fix is possible, but required invading into WebKit internals (actually, -[UIWebSelectPopover _userActionDismissedPopover:] method interception and delaying call to accessoryDone).

Do you have any links or tutorial that would help me achieve that ?

Indeed the build with xcode 8 on ios 11 is solving the issue. But i don't think it is a consistent and long term solution. Do you have any idea if it will be fixed in the future xcode 9 versions ? or where can i contact the apple team to keep them aware of this issue. Thanks !

We had same problem with HTML select component, we were able resolve this issue by swizzling presentviewcontroller.

Could you please post your solution?

Is there any solution for this problem?

I am also getting this issue in XCode 9.0 and iOS 11.0.3

As posted previously, it seems the current work-around is to build your solution using xcode 8.


A workaround I am currently looking in to is by using jquery mobile to override the native select box behavior.


<script src="[path to jquery mobile]"></script>
...
<select data-native-menu="false">
     <option>Option 1</option>
     <option>Option 2</option>
     ...
</select>


Personally, i'm not a huge fan of jQuery mobile, but this does save time versus creating a custom handler in javascipt to handle select boxes. jQuery mobile can be found @ jquerymobile.com


Another option is that I have heard that using an alternate webview works. I think it is WKWebView or something along those lines. I don't program in xcode, so I am not familiar with it, nor have I dabbled with it.


Also, not sure if anyone else has mentioned it, but select box behavior seems to be working fine on iPhone devices. iPhones seem to handle the select box differently than their tablet counterparts.


Hope this helps.

Here is the soluntion for all the issue with html select option


Header file:

#import <Foundation/Foundation.h>
@interface NSObject(SwizzleUIPopOver)
@end


Implementation:

#import "NSObject+SwizzleUIPopOver.h"
#import <objc/runtime.h>
@implementation NSObject(SwizzleUIPopOver)
BOOL alreadyloaded=false;
+(void)load {
    static dispatch_once_t onceToken;

    dispatch_once(&onceToken, ^{
   
        Class class = [self class];
   
        int numClasses = objc_getClassList(NULL, 0);
        Class *classes = NULL;
   
        /
        /
        classes = (__unsafe_unretained Class *)malloc(sizeof(Class) * numClasses);
        numClasses = objc_getClassList(classes, numClasses);
        for (NSInteger i = 0; i < numClasses; i++)
        {
            Class superClass = classes[i];
            const char * name=class_getName(classes[i]);
            NSString *nameOfClass=[NSString stringWithUTF8String:name];
            if([nameOfClass isEqual:@"UIWebSelectPopover"])
            {
                do
                {
                    superClass = class_getSuperclass(superClass);
                } while(superClass && superClass != class);
           
                if (superClass == nil)
                {
                    continue;
                }
                [self swizzleClassWithUserActionDismissedPopover:classes[i]];
            }
            else if([nameOfClass isEqual:@"UIWebFormRotatingAccessoryPopover"])
            {
                do
                {
                    superClass = class_getSuperclass(superClass);
                } while(superClass && superClass != class);
           
                if (superClass == nil)
                {
                    continue;
                }
                [self swizzleClassWithAccessporyDone:classes[i]];
            }
       
        }
   
        free(classes);
    });
}
-(void)byPass_accessoryDone{
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
        [self byPass_accessoryDone];
    });
}
-(void)byPass_userActionDismissedPopover:(id)arg1{
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, .5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
        [self byPass_accessoryDone];
    });
}
+ (void)swizzleClassWithAccessporyDone:(Class)class
{
    /
    SEL originalShouldSelector = @selector(accessoryDone);
    SEL swizzledShouldSelector = @selector(byPass_accessoryDone);

    Method originalShouldMethod = class_getInstanceMethod(class, originalShouldSelector);
    Method swizzledShouldMethod = class_getInstanceMethod(class, swizzledShouldSelector);

    BOOL didAddShouldMethod = class_addMethod(class, originalShouldSelector, method_getImplementation(swizzledShouldMethod), method_getTypeEncoding(swizzledShouldMethod));

    if (didAddShouldMethod) {
        class_replaceMethod(class, swizzledShouldSelector, method_getImplementation(originalShouldMethod), method_getTypeEncoding(originalShouldMethod));
    }
    else {
        method_exchangeImplementations(originalShouldMethod, swizzledShouldMethod);
    }
}
+(void)swizzleClassWithUserActionDismissedPopover:(Class) class{
    SEL originalSelector = @selector(_userActionDismissedPopover:);
    SEL swizzledSelector = @selector(byPass_userActionDismissedPopover:);

    Method originalMethod = class_getInstanceMethod(class, originalSelector);
    Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);

    BOOL didAddMethod = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));

    if (didAddMethod) {
        class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
    }
    else {
        method_exchangeImplementations(originalMethod, swizzledMethod);
    }
}
@end



But this the swizzle mehtod. works like a charm on our enterprise application

Hi rsindogi,


Where should we invoke above class methods you mentioned?

Do I need to invoke from our viewController or invoke somewhere in UIWebviewDelegate ?


Thank You.

This bug working fine in iOS 11.2.