Disabling magnification in WKWebView by Paulo Fierro

On a current project we're using the newly introduced (in iOS 8) and mostly awesome WKWebView to show custom HTML content. Now for some very specific reasons I can't get into, we need to disable the pinch-to-zoom gesture for all the pages that are displayed.

Luckily WKWebView has an allowsMagnification property to do just this, but unfortunately this and the other properties that allow you to modify the magnification are only available on OS X.

But all is not lost, we can attach our own custom Javascript to any page that we load. And with a little help from Javascript we can create a meta tag that disables scaling of the viewport and inject it into the document's <head>.

Once we have this Javascript we can create a WKUserScript object which we tell the WKUserContentController to always inject into loaded pages, and pass that controller to a WKWebViewConfiguration object, which is used when we create our WKWebView.

That sounds like a mouthful but its quite straightforward. Paste code the code below into a UIViewController's viewDidLoad method to try it out.

UPDATE: Initially I had written that we were loading arbitrary content from around the web which wasn't strictly the case and also caused a few people to suggest that this was a bad thing. Absolutely 100% agree. However in this specific case we are loading custom content, produced in-house and requires the gesture to be disabled.

Otherwise you probably should never do this.

And the same thing in Swift for funsies:

Embedding Gists on Squarespace by Paulo Fierro

I'm a big fan of Squarespace and the new platform is very well done. There are however a few things now and then that confuse me and one of these is embedding gists from Github.

I thought you'd use an Embed block for this, but for some reason this doesn't work.

The obvious choice?

The obvious choice?



Instead you have to scroll down (or search for) the Code block and paste the embed script in there.

The not so obvious choice

The not so obvious choice

Not quite as obvious as I thought, but at least it works.

Below is a random gist I use for converting WAV files to CAF for embedding in iOS apps:

The screenshots were edited in Napkin. Its great, you should try it.

Google Chrome gets fatter and fatter by Paulo Fierro

I ran DaisyDisk the other day to reclaim some lost disk space and found some oddities. One of these was Google Chrome using over 4GB in my Applications folder.

A browser really shouldn't require 4GB of space. So I emptied Chrome's cache, but that didn't affect the overall size at all.

I peeked inside (right-clicking on Chrome and selecting Show Package Contents) and in Contents/Versions I found this:

So many Chromes!

Chrome was storing a backup of itself, presumably every time it did an auto-update. As far as I see tell there is no way to delete these backups from within Chrome or turning off this behaviour.

Deleting all of them but not the newest one didn't seem to make a difference — Chrome works fine and I got some disk space back.

Of course if this crashes your Mac and it bursts into flames that's on you :-)

Dipping my toes into the future by Paulo Fierro

Last night I decided to get my toes wet with iOS 8 + Swift. There are so many, many goodies in iOS 8 as well as a whole new language to learn so I fired up the Xcode 6 Beta, put on the WWDC 2014 session on "Creating Extensions for iOS and OS X, Part1" (#205) and got to work.

A little while later I had an extremely simple app but most importantly a working Today Extension.

Oh yeah!

How many steps have you taken today?

This morning I cleaned it up and uploaded it to Github. These things really have the possibility of being awesome.

I'm very excited for the fall!

Brainfeed in the Spotlight by Paulo Fierro

A little over two months ago we launched Brainfeed — an educational app for iPad that we built for a great client in the US.

We loved the idea behind the app and worked hard to sweat the little details striving to make the app fast, fluid and fun. We collaborated with Anne-Sophie Leens on the visual design front — we'd worked with her before and knew that she'd be a perfect fit for the project.

Post-launch the app was steadily getting some attention. Interestingly it did really well very quickly in parts of Africa and South-East Asia where it shot up the charts. It got into the top 10 in a couple weeks in countries like Nigeria, Kenya, Egypt and the Philippines.

Then Europe took notice. First it started climbing the charts in the Eastern countries and slowly moved westward. Then on a Saturday afternoon our client got an email from Apple requesting artwork as the app was being considered for promotion.

This could be huge.

It was on a weekend and I was away so we couldn't provide any help but they scrambled and got the material together and submitted it right before the deadline and then we waited. And waited.

And then this happened.

App Store banner

App Store banner

This banner started appearing in the App Store in some countries. First as a small banner, but then eventually the main banner at the top of the store. Placing our app alongside other apps and games from the likes of Disney, EA and Nickelodeon.

Main banner for Kids 9-11 in the UK App Store — April 27, 2014

This was absolutely amazing.

When an app is published you have to choose two categories that it should belong to that make sense. For Brainfeed this was Kids and Education, though for Kids you have to specify an additional age range — so it kind of gets three categories.

Reaching the #1 spot for Kids 9-11 was no mean feat (its done so in 64 countries thus far), but it also started rising slowly in the more general Kids category and then Education which is massive.

While this was happening the app started to get noticed in the States and landed on the #4 spot for Best New Apps in the US App Store.

US App Store: Best New Apps — April 27, 2014

As you can imagine this was huge for visibility.

And then this weekend, the app got another major spike when Apple featured it in the iTunes Education Spotlight (in the Canadian one too). Still there as of this writing and immortalized forever in the screenshot below.

iTunes Education Spotlight featuring Brainfeed — May 26, 2014

This is the first time I've worked on an app that's gained so much exposure.

One thing is rising up the charts and reaching:

  • #1 for Kids: Ages 9–11 in 64 countries
  • #1 for Kids in 23 countries
  • #1 for Education in 17 countries
  • reaching #4 in the US in Kids: Ages 9–11

However for me getting the app featured by Apple means much more. A prominent spot in a newsletter that goes out to teachers and parents means we definitely did something right, and that's certainly something I am very proud of.