天天看点

ios 开发 去掉H5 alert 中的网址

去掉弹框中的网址

UIWebView直接加载的H5界面,弹出 alert 往往会出现这样的情况

ios 开发 去掉H5 alert 中的网址

这时候我们需要做的,就是自定义alert风格

直接上代码

@interface NSObject (JavaScriptAlert)


- (void)WebView:(UIWebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame;

@end           
#import "NSObject+YOAlert.h"

@implementation NSObject (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