美文网首页
iOS修改js弹出框样式

iOS修改js弹出框样式

作者: fallrainy | 来源:发表于2016-06-24 18:02 被阅读698次

ios 中webview默认的弹框标题为链接域名,比较难看,假如我们想把标题改为“提示消息”要怎么做呢?可以通过给UIWebview添加category的方式实现,代码如下:

@interface UIWebView (JavaScriptAlert)

- (void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame;
@end

@implementation UIWebView (JavaScriptAlert)

- (void)webView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame {
  UIAlertView* customAlert = [[UIAlertView alloc] initWithTitle:@"提示信息" message:message delegate:nil  cancelButtonTitle:@"确定" otherButtonTitles:nil];
     [customAlert show];
}

@end

只要导入这个category,就可以修改将网页js弹出框标题为 “提示信息”了。

相关文章

网友评论

      本文标题:iOS修改js弹出框样式

      本文链接:https://www.haomeiwen.com/subject/vfnodttx.html