[MonoTouch] UIWebView load from string
Craig Dunn
craig.dunn at conceptdevelopment.net
Tue Oct 20 21:50:54 EDT 2009
I've just tapped this out in email - so it may not compile...
// load and save the html string (in /Documents/ folder)
var documentsDirectory = Environment.GetFolderPath
(Environment.SpecialFolder.Personal);
var htmlPath = Path.Combine (documentsDirectory, "cached.html");
Uri uri = new Uri("http://somesite.com/default.html");
WebClient wc = new WebClient();
try
{
wc.DownloadFile (uri, htmlPath); // saves to filesystem
}
catch (Exception ex) {Console.Write("oops");}
// then load
var htmlString = System.IO.File.ReadAllText(htmlPath);
// and display
webView.LoadHtmlString(htmlString, null);
of course you will want to split up these two pieces of code...
HTH
cd
On Wed, Oct 21, 2009 at 10:44 AM, Ali Shafai <Ali at platysoft.com.au> wrote:
> Hi there,
> I need to have a UIWebView that loads it's content from a nsstring, however
> I want to be able to download an html from my website whenever the phone can
> and replace the string with the new one from my website. I don't know how to
> download an html file and save it as a nsstring.
>
> any help is appreciated.
>
> --
> Cheers,
> Ali
>
> _______________________________________________
> MonoTouch mailing list
> MonoTouch at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monotouch/attachments/20091021/a3a0eff1/attachment.html
More information about the MonoTouch
mailing list