Ogre Codes

Follow @ogre_codes to get notified when new articles are posted to this site.


Added an "Instant" Preview 👨🏻‍💻

Feb 18, 2017 at 10:42 PM

It took about a day of banging my head against the wall, a lot of research, and a ton of fighting "auto"layout but I managed to cook up a fairly solid auto-updating preview pane that even reads the CSS for the page.

I tried to use the built in "DownView" included with the MarkDown parser I'm using, but the View built into it seems to be a bit... glitchy and it turns out it's much simpler just to use a WebView and pipe the HTML the Markdown encoder cranks out directly. This works out better regardless because I can support the templates and CSS I use and actually preview the exact page output as I'll see it.

This adventure of course included the required struggle with autolayout and Interface Builder, but I think I'm starting to get the hang of it because it only took me an hour or so to work out how to get the webview added in the way I want. Lesson of the day is: Stack Views aren't as magical as Apple would have you believe. Overall I'm very happy with the results.