开发者

<select> tag doesn't work in UIWebView on iOS4

I'm new to iOS programming, so please allow me to ask stupid questions if it is :)

I have a program, using UIWebView to load HTML page and display to the end users.

The page is quite simple,

<select>
    <option>A</option>
    <option>B</option>
    <option>C</option>
    <option>D</option>
</select>

WebView controller init:
WebViewController *webVC = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:nil];

Load the HTML page in this way:

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://*****/app/"]]];

When program started, the end user will see a drop down menu, if click the menu, end user will see a list of options, then choose one of then.

The problem is, it works fine in iOS3.2, but after I upgrade the SDK to iOS4, it doesn't work, nothing happen when 开发者_JAVA百科click the drop down menu.

Can anyone help me?

Is there anything wrong with my UIWebView?

Thanks a lot.


Load the HTML page in this way:

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://*****/app/"]]];


I ran into the same Problem.

In my case it was a Category on UIView I recently defined to dismiss the keyboard. Every time the user touches a view I call endEditing:YES on the super view and resign the first responder state of the superview and all of its subviews.

This worked fine until I the first time I had a html select/option in a UIWebView. I was not able to select the entries. I was a litte confused because with a UIPickerView in my native code it wasn't a problem either.

The Problem was, that I was touching a UIPickerTableViewWrapperCell which is a UITableViewCell and this is -- a UIView! By resigning the first responder of the UIPickerTableViewWrapperCell functionality of the PickerView was broken.

The solution was to get the superview of the view and check the classes and make exceptions:

#import "UIView+KeyboardDismisser.h"

@implementation UIView (KeyboardDismisser)

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    if(([[self superview] superclass] == [UITableViewCell class]) ||([[self superview] superclass] == [UITableView class])  )
    {
        [super touchesBegan:touches withEvent:event]; 
    }
    else
    {
       [[self superview] endEditing:YES];
    }
}
@end

So watch out for such global hooks on central elements like UIView and make exceptions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜