forked from organicmaps/organicmaps
[ios] Open links from About in Safari
This commit is contained in:
parent
e5e83c7a8f
commit
0c7577d015
3 changed files with 16 additions and 1 deletions
|
@ -1,9 +1,11 @@
|
|||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface WebViewController : UIViewController
|
||||
@interface WebViewController : UIViewController <UIWebViewDelegate>
|
||||
|
||||
@property (nonatomic) NSURL * m_url;
|
||||
@property (nonatomic) NSString * m_htmlText;
|
||||
// Set to YES if external browser should be launched
|
||||
@property (nonatomic) BOOL openInSafari;
|
||||
|
||||
- (id)initWithUrl:(NSURL *)url andTitleOrNil:(NSString *)title;
|
||||
- (id)initWithHtml:(NSString *)htmlText baseUrl:(NSURL *)url andTitleOrNil:(NSString *)title;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
// webView.scalesPageToFit = YES;
|
||||
webView.autoresizesSubviews = YES;
|
||||
webView.autoresizingMask = (UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
|
||||
webView.delegate = self;
|
||||
|
||||
if (self.m_htmlText)
|
||||
[webView loadHTMLString:self.m_htmlText baseURL:self.m_url];
|
||||
|
@ -50,4 +51,15 @@
|
|||
return YES;
|
||||
}
|
||||
|
||||
-(BOOL)webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType
|
||||
{
|
||||
if (self.openInSafari && inType == UIWebViewNavigationTypeLinkClicked)
|
||||
{
|
||||
[[UIApplication sharedApplication] openURL:[inRequest URL]];
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -150,6 +150,7 @@ Settings::Units unitsForIndex(NSInteger index)
|
|||
NSString * str = [NSString stringWithFormat:@"Version: %@ \n", [[NSBundle mainBundle] infoDictionary][@"CFBundleVersion"]];
|
||||
NSString * text = [NSString stringWithFormat:@"%@%@", str, [NSString stringWithUTF8String:s.c_str()]];
|
||||
WebViewController * aboutViewController = [[WebViewController alloc] initWithHtml:text baseUrl:nil andTitleOrNil:NSLocalizedString(@"about", nil)];
|
||||
aboutViewController.openInSafari = YES;
|
||||
[self.navigationController pushViewController:aboutViewController animated:YES];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue