我正在尝试打开一个从javascript弹出警报的网址。我在我的应用程序中有一个UIWebview调用url。我无法在UIWebview中加载该URL。我可以在哪种方式显示UIAlertview?请帮帮我。我在我的viewcontroller中完成了这些步骤
在我的.h文件中
@interface ViewController : UIViewController<UIWebViewDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@end
在我的.m文件中 - (void)viewDidLoad { [super viewDidLoad]; //在加载视图后进行任何其他设置,通常是从笔尖。
NSString * strUrl = @"https://something-stg1.euw.abc.net/";
// NSString * strUrl = @"https://gmail.com";
NSURLRequest * REQ = [NSURLRequest requestWithURL:[NSURL URLWithString:strUrl]];
_webView.delegate = self;
[_webView loadRequest:REQ];
}
-(BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = request.URL;
NSString *urlString = url.absoluteString;
NSLog(@"urlstring is %@", urlString);
// Only catching links without "mobile" in the url (i.e. stories)
return YES;
}
- (void)loadRequest:(NSURLRequest *)request
{
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
NSLog(@"webViewDidStartLoad");
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
NSLog(@"webViewDidFinishLoad");
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
NSLog(@"%@",[error description]);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}