src: ios_browser: Add support for webview
Add webview support for kivy-ios. Any URL can be opened in webview by just doing the following: ``` import ios url = "http://www.google.com" ios.IOSWebView().open(url) ``` Tested:OK
This commit is contained in:
parent
8fe8fbf57e
commit
9944c82c7c
1 changed files with 27 additions and 0 deletions
|
@ -11,3 +11,30 @@ void ios_open_url(char *url)
|
|||
NSString *nsurl = [NSString stringWithCString:(char *)url encoding:NSUTF8StringEncoding];
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: nsurl]];
|
||||
}
|
||||
|
||||
/*
|
||||
* Webview support
|
||||
*/
|
||||
void load_url_webview(char *url)
|
||||
{
|
||||
NSString *nsurl = [NSString stringWithCString:(char *)url encoding:NSUTF8StringEncoding];
|
||||
UIWebView *webView = [[UIWebView alloc] initWithFrame: CGRectMake(0, 0, 320, 480)];
|
||||
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
|
||||
UIView *view = [window.rootViewController view];
|
||||
[view addSubview:webView];
|
||||
NSURL *ur = [[NSURL alloc] initWithString: nsurl];
|
||||
NSURLRequest *req = [[NSURLRequest alloc] initWithURL: ur];
|
||||
[webView loadRequest: req];
|
||||
[req release];
|
||||
[ur release];
|
||||
|
||||
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
|
||||
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
||||
[button setTitle:@"X" forState:UIControlStateNormal];
|
||||
button.frame = CGRectMake(0.0, 0.0, 40, 40);
|
||||
[button addTarget:webView
|
||||
action:@selector(removeFromSuperview) forControlEvents:UIControlEventTouchDown];
|
||||
[webView addSubview:button];
|
||||
[button release];
|
||||
[webView release];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue