|
|
|
|
643
|
- (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString *))completionHandler{
|
643
|
- (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString *))completionHandler{
|
644
|
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:prompt preferredStyle:UIAlertControllerStyleAlert];
|
644
|
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:prompt preferredStyle:UIAlertControllerStyleAlert];
|
645
|
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
|
645
|
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
|
646
|
- textField.textColor = [UIColor lightGrayColor];
|
|
|
647
|
- textField.placeholder = defaultText;
|
|
|
|
|
646
|
+ textField.text = defaultText;
|
648
|
}];
|
647
|
}];
|
649
|
- [alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
|
|
|
|
648
|
+ UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
650
|
completionHandler([[alert.textFields lastObject] text]);
|
649
|
completionHandler([[alert.textFields lastObject] text]);
|
651
|
- }]];
|
|
|
|
|
650
|
+ }];
|
|
|
651
|
+ [alert addAction:okAction];
|
|
|
652
|
+ UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
|
|
|
653
|
+ completionHandler(nil);
|
|
|
654
|
+ }];
|
|
|
655
|
+ [alert addAction:cancelAction];
|
|
|
656
|
+ alert.preferredAction = okAction;
|
652
|
[[self topViewController] presentViewController:alert animated:YES completion:NULL];
|
657
|
[[self topViewController] presentViewController:alert animated:YES completion:NULL];
|
653
|
}
|
658
|
}
|
654
|
|
659
|
|