- (void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame {
NSLog(@"javascript alert : %@",message);
UIAlertView* customAlert = [[UIAlertView alloc] initWithTitle:@"test" message:message delegate:nil cancelButtonTitle:@"확인" otherButtonTitles:nil];
[customAlert show];
}
- (BOOL)webView:(UIWebView*)sender runJavaScriptConfirmPanelWithMessage:(nonnull NSString *)message initiatedByFrame:(nonnull WKFrameInfo *)frame completionHandler:(nonnull void (^)(BOOL))completionHandler{
UIAlertView* customAlert = [[UIAlertView alloc] initWithTitle:@"test" message:message delegate:nil cancelButtonTitle:@"확인" otherButtonTitles:@"취소", nil];
[customAlert show];
return true;
}
我想在javascript提醒或确认时更改UIAlertView的标题 弹出对话框。
javascript警报似乎工作正常,但在使用javascript确认对话框时,
该对话框未显示应该执行的自定义标题。
你们可以提出任何想法吗?任何帮助将非常感激。
答案 0 :(得分:0)
错误的实施。应该删除这个问题,但不知道如何。
.h文件
-(void)webView:(UIWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame;
- (BOOL)webView:(UIWebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame;
.m文件
- (BOOL)webView:(UIWebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame {
UIAlertView *confirmDiag = [[UIAlertView alloc] initWithTitle:@"test" message:message delegate:self cancelButtonTitle:NSLocalizedString(@"예", @"예") otherButtonTitles:NSLocalizedString(@"아니오", @"아니오"), nil];
[confirmDiag show];
while (confirmDiag.hidden == NO && confirmDiag.superview != nil) {
[[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01f]];
}
return diagStat;
}
- (void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame {
NSLog(@"javascript alert : %@",message);
UIAlertView* customAlert = [[UIAlertView alloc] initWithTitle:@"test" message:message delegate:nil cancelButtonTitle:@"확인" otherButtonTitles:nil];
[customAlert show];
}