Hi,
I am bringing an iOS app over to forms and for the most part, it's not been too difficult. Okay, a bit sluggish in some parts for Android and with some very odd results on WinPhone, but on the whole, it's good.
Part of the UI has web view within the VC which has a table rendered in, the last element of which is a html link.
The table is generated like this
wvLCData.LoadHtmlString(string.Empty, null);
var documents = NSBundle.MainBundle.BundlePath;
var sb = new StringBuilder();
sb.Append(File.ReadAllText(Path.Combine(documents, "HTML/top3.html")));
sb.Append(@"<table width=100%>");
foreach (var m in mobEvents)
{
var image = string.Format("<a href=\"id={0}\"><img src={1} width=\"25px\" height=\"25px\" /></a>", m.Id, NSBundle.PathForResourceAbsolute("rightarrow", "png", Path.Combine(documents, "HTML")));
sb.Append(string.Format("<tr><td width=\"10%\">{0}</td><td width=\"85%\">{1}</td><td width=\"5%\">{2}</td></tr>", m.Date.ToShortDateString(), m.Summary, image));
}
sb.Append(@"</table>");
sb.Append(File.ReadAllText(Path.Combine(documents, "HTML/bottom.html")));
wvLCData.LoadHtmlString(sb.ToString(), new NSUrl(""));
wvLCData.ShouldStartLoad += HandleStartLoad;
This works fine. When the link is clicked, the following is fired off
public bool HandleStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navType)
{
int m = 0;
Console.WriteLine(navType.ToString());
if (navType == UIWebViewNavigationType.LinkClicked)
{
if (request.Url.RelativeString.Contains("id="))
{
var id = request.Url.RelativeString.Split('=').ToArray()[1];
var ev = AppDelegate.Self.DBManager.GetSingleObject<Events>("id", id);
var vw = new EventEdit(StringUtils.GetString("ChemType.Cropping"), ev, View, true);
/*vw.Frame = new CGRect(8, 30, 300, 357);
View.Add(vw);*/
}
}
Console.WriteLine("out");
return true;
}
Is there something similar that can be done with Forms directly or do I need implement a custom web view to do this and handle the ShouldStartLoad
(as well as the Droid/WP equivalents) there?
Given how my day is going, I'll bet my left sandal it's a custom view