我的应用程序连接到Instagram,所以我需要一个webview来呈现Instagram登录HTML页面。 UIWebView中显示的用于uname和pass的输入字段是可选择的并接受输入。登录按钮无法点击。来自UIWebView的相关.m文件代码和HTML如下所示。
的.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.webView.delegate = self;
self.usernameField.delegate = self;
self.passwordField.delegate = self;
self.webView.scalesPageToFit = YES;
self.request = [[NSURLRequest alloc]initWithURL:self.url];
[_webView loadRequest:self.request];
NSLog(@"NSURL on webview %@", self.request);
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
NSLog(@"%@",
[_webView stringByEvaluatingJavaScriptFromString:
@"document.body.innerHTML"]);
_webView.opaque = YES;
}
<p><label for="id_password">Password:</label> <input autocapitalize="off" autocorrect="off" type="password" name="password" id="id_password"></p>
<p class="form-actions">
<a href="/accounts/password/reset/">Forgot password?</a>
<input type="submit" class="button-green" value="Log in">
</p>
</form>
</div>
</div>
</section>
<script>
$(window).load(
function() {
$("#id_username").focus();
}
);
</script>
<div id="reactModalMountPoint"></div>
</div>