Skip to main content

Posts

Showing posts from February, 2019

Open Graph and Facebook: The Basics (Text, Images and App ID)

There are some basics you need to know when working with Facebook's Open Graph to tag your webpages. Descriptive Elements Let's start with the descriptive elements: url, type, title and description. For a website we can fill these out in the following way: <!-- Facebook Open Graph --> <meta property="og:url" content="https://www.gylphi.co.uk" /> <meta property="og:type" content="website" /> <meta property="og:title" content="Gylphi: Arts and Humanities Publisher" /> <meta property="og:description" content="Academic publisher of the arts and humanities from the twentieth century and beyond." /> The property values are hopefully clear enough to understand but are  expanded on here . Images One of the most important factors you'll want to include are images. Images should be a minimum of 600 px wide, but preferably 1080px wide (see  https://developers.faceb

Link Sharing and Search Optimisation using Facebook's Open Graph, Twitter Cards and Structured Data (JSON-LD)

This isn't a post taking you through the creation of metadata and markup for link sharing and search optimisation. (Sorry! Maybe another time.) It is instead a series of getting started links to help guide you towards what you need to include in your webpages to control how your pages get seen on the web from outside your website. Facebook: Open Graph Instructions for controlling title and image content that are paired with shared links are given here: https://developers.facebook.com/docs/sharing/webmasters Content types include: music, video, article, book, profile and website. The website type being the default. For information on adding rich detail to the type, see here: http://ogp.me Sharing debugger:  https://developers.facebook.com/tools/debug/ Twitter: Cards Twitter has a fallback of using open graph but with twitter cards you have rich functionality unique to Twitter: https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/abouts-cards

Nesting a UIStackView within a UIScrollView: Horizontal Scrolling

Horizontal Scrolling (UIStackView within UIScrollView) For horizontal scrolling. First, create a `UIStackView` and a `UIScrollView` and add them to your view in the following way: let scrollView = UIScrollView() let stackView = UIStackView() scrollView.addSubview(stackView) view.addSubview(scrollView) Remembering to set the `translatesAutoresizingMaskIntoConstraints` to `false` on the `UIStackView` and the `UIScrollView`: stackView.translatesAutoresizingMaskIntoConstraints = false scrollView.translatesAutoresizingMaskIntoConstraints = false To get everything working the trailing, leading, top and bottom anchors of the `UIStackView` should be equal to the `UIScrollView` anchors: stackView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor).isActive = true stackView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor).isActive = true stackView.topAnchor.constraint(equalTo: scrollView.topAnchor).isActive = true stackView.bottomAnchor.constraint(equalTo: scroll

The Weird and Auto-Magical Science of Integrating TextKit with UIPageViewController and Auto Layout

Let's suppose you are using TextKit to layout your text, i.e. the combination of NSTextStorage, NSLayoutManager and NSTextContainer, combined with UITextView. And let's also suppose that you'll be using Auto Layout to anchor a UIPageViewController's view to the views it will be sitting next to (or perhaps be using it within a UIStackView, you brave soul!). func textLayoutContainers(size:CGSize, scrolling:Bool, section:String, page:Int) { var textViewArr = [UITextView]() // Create attr string - content guard let textString = loadHTMLData(section: section, page: page) else {return} // Set up text storage and add string let textStorage = NSTextStorage(attributedString: textString) // Create a layout manager let textLayout = NSLayoutManager() // Add layout manager to text storage object textStorage.addLayoutManager(textLayout) // create text containers and views, adding eac