Make webview window size customizable
Webview window size can now be passed as a parameter to `open` function of IOSWebview.
This commit is contained in:
parent
7ab642c65d
commit
c212f02167
3 changed files with 15 additions and 9 deletions
|
@ -14,7 +14,7 @@ cdef extern from "ios_wrapper.h":
|
||||||
int ios_send_email(char *subject, char *text, char *mimetype, char
|
int ios_send_email(char *subject, char *text, char *mimetype, char
|
||||||
*filename, char *filename_alias, ios_send_email_cb cb, void *userdata)
|
*filename, char *filename_alias, ios_send_email_cb cb, void *userdata)
|
||||||
void ios_open_url(char *url)
|
void ios_open_url(char *url)
|
||||||
void load_url_webview(char *url)
|
void load_url_webview(char *url, int width, int height)
|
||||||
float ios_uiscreen_get_scale()
|
float ios_uiscreen_get_scale()
|
||||||
int ios_uiscreen_get_dpi()
|
int ios_uiscreen_get_dpi()
|
||||||
|
|
||||||
|
@ -27,11 +27,11 @@ cdef void _send_email_done(char *status, void *data):
|
||||||
#Support for iOS webview
|
#Support for iOS webview
|
||||||
#
|
#
|
||||||
class IOSWebView(object):
|
class IOSWebView(object):
|
||||||
def open(self, url):
|
def open(self, url, width, height):
|
||||||
open_url_wbv(url)
|
open_url_wbv(url, width, height)
|
||||||
|
|
||||||
|
|
||||||
def open_url_wbv(url):
|
def open_url_wbv(url, width, height):
|
||||||
'''
|
'''
|
||||||
OPEN URL in webview
|
OPEN URL in webview
|
||||||
|
|
||||||
|
@ -39,13 +39,19 @@ def open_url_wbv(url):
|
||||||
`url`: str
|
`url`: str
|
||||||
URL string
|
URL string
|
||||||
|
|
||||||
|
`height`: int
|
||||||
|
Height of the window
|
||||||
|
|
||||||
|
`width`: int
|
||||||
|
Width of the window
|
||||||
|
|
||||||
Example for opening up a web page in UIWebview::
|
Example for opening up a web page in UIWebview::
|
||||||
|
|
||||||
import ios
|
import ios
|
||||||
url = "http://www.google.com"
|
url = "http://www.google.com"
|
||||||
ios.IOSWebView().open(url)
|
ios.IOSWebView().open(url, width, height)
|
||||||
'''
|
'''
|
||||||
load_url_webview(url)
|
load_url_webview(url, width, height)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Support for webbrowser module
|
# Support for webbrowser module
|
||||||
|
|
|
@ -15,10 +15,10 @@ void ios_open_url(char *url)
|
||||||
/*
|
/*
|
||||||
* Webview support
|
* Webview support
|
||||||
*/
|
*/
|
||||||
void load_url_webview(char *url)
|
void load_url_webview(char *url, int width, int height)
|
||||||
{
|
{
|
||||||
NSString *nsurl = [NSString stringWithCString:(char *)url encoding:NSUTF8StringEncoding];
|
NSString *nsurl = [NSString stringWithCString:(char *)url encoding:NSUTF8StringEncoding];
|
||||||
UIWebView *webView = [[UIWebView alloc] initWithFrame: CGRectMake(0, 0, 320, 480)];
|
UIWebView *webView = [[UIWebView alloc] initWithFrame: CGRectMake(0, 0, width, height)];
|
||||||
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
|
UIWindow *window = [[UIApplication sharedApplication] keyWindow];
|
||||||
UIView *view = [window.rootViewController view];
|
UIView *view = [window.rootViewController view];
|
||||||
[view addSubview:webView];
|
[view addSubview:webView];
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
float ios_uiscreen_get_scale(void);
|
float ios_uiscreen_get_scale(void);
|
||||||
int ios_uiscreen_get_dpi(void);
|
int ios_uiscreen_get_dpi(void);
|
||||||
void ios_open_url(char *url);
|
void ios_open_url(char *url);
|
||||||
void load_url_webview(char *url);
|
void load_url_webview(char *url, int width, int height);
|
||||||
|
|
||||||
typedef void (*ios_send_email_cb)(char *, void *);
|
typedef void (*ios_send_email_cb)(char *, void *);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue