Merge pull request #10 from lemarier/feat/webview-load-url-string
feat(webview): Allow loading of HTML string instead of URL.
This commit is contained in:
commit
33123c6790
|
@ -253,6 +253,18 @@ impl<T> WebView<T> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Given a HTML string, instructs the WebView to load it.
|
||||||
|
/// Useful for small html files, but often better to use custom protocol.
|
||||||
|
pub fn load_html(&self, html_string: &str) {
|
||||||
|
let html = NSString::new(html_string);
|
||||||
|
let blank = NSString::no_copy("");
|
||||||
|
|
||||||
|
self.objc.with_mut(|obj| unsafe {
|
||||||
|
let empty: id = msg_send![class!(NSURL), URLWithString:&*blank];
|
||||||
|
let _: () = msg_send![&*obj, loadHTMLString:&*html baseURL:empty];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// Go back in history, if possible.
|
/// Go back in history, if possible.
|
||||||
pub fn go_back(&self) {
|
pub fn go_back(&self) {
|
||||||
self.objc.with_mut(|obj| unsafe {
|
self.objc.with_mut(|obj| unsafe {
|
||||||
|
|
Loading…
Reference in a new issue