Seth Godin recently published a short post called “The full stack keeps getting taller”, in which he basically advices us to leave a particular field of interest as soon as it’s taken for granted - when it becomes part of the lower stack. A commodity, perhaps.
However, while top of the stack changes quickly, the bottom of the stack changes slowly.
It’s the principle of inertia. If you have two soccerballs, and one is filled with lead instead of air, then you’d need to apply more work to accelerate it to the same speed as the other.
What I mean is this: There’s much more built on top of TCP/IP than there is, for instance, on top of Gulp.js.
And if it’s easier to go from the basics to a specialization than vice versa , it pays to have a solid foundation, and a good grasp of core technologies.
This way, jumping from technology to technology should require much less effort.
 I think this is the case, especially if we have not neglected to learn new things in the past. If we ever only cared about Java programming, and never bothered to look at Assembler or Clojure, we might end up a one trick pony. But if there’s a little experience in different fields under our belt, we get very good at adapting.
It was fun to do and I learned a bunch of stuff about Mac OS X. It was probably also the last side-project ever written in Objective-C for me, since the Apple world is switching to Swift now. (Which is good.)
Sadly, I cannot distribute the app through the AppStore, because it cannot be sandboxed using the APIs it does (Accessibility). Which means I will probably never earn enough money to buy a happy meal with it.
I had a UIPageViewController in scrolling-mode that would allow to pan between view-controllers using a finger gesture. However, I wanted to restrict the panning area to a certain area of the screen, for example as shown in this screenshot:
I do it by subclassing the UIPageViewController, finding its UIScrollView, and adding a new UIPanGestureRecognizer to that scrollView.
I set my subclassed UIPageViewController to be the delegate of that new UIPanGestureRegognizer. I then implement two delegate methods:
In the last override I decide if I want to “eat the event” (reply YES) or if I want the original UIPanGestureViewRecognizer of the UIScrollView to handle it (reply NO). So, the YES-reply means the UIPageViewController will not scroll to the next ViewController.
Here are two code snippets for rotating and resizing UIImage’s without using UIGraphicsBeginImageContext(), because it is not thread-safe and can lead to weird behavior.
In my case the camera-preview when taking a picture in an app I was writing, turned black from time to time. The problem was that I was rotating and resizing the images using UIGraphicsBeginImageContext().
Here’s some code I’ve found and tweaked to resize images:
And here’s how to rotate them:
Because the above takes radians, convert using something like this:
Just put these methods into a category on UIImage.
This kept me busy for a while until I found a super simple way to do it: In this tutorial/code-snippet I’ll show you how to write an image-cropper for your iPhone-app.
What do I mean by image-cropper?
Bascially, it’s about giving your users a simple way to select part of an image using pan and pinch gestures. This can be handy when they upload a profile picture or something similar.
Here’s the end result:
How it’s done:
There is one UIScrollView with a large contentSize. Embedded in the scroll-view is a UIView (baseView). And embedded in the baseView is the UIImageView with the Ferrari-picture.
The yellow boxes in the above image represent the iPhone screen and the cropping area.
Because the contentSize is bigger than the bounds of the screen (= frame of _scrollView), the user can pan to select the desired image. Because minimumZoomScale and maximumZoomScale are set, the user can pinch to zoom. (Although I am not sure why it helps to set the initial zoomScale after all other initialization. If it’s done earlier it won’t scroll until zoomed.)
The actual cropping is done by rendering the contents of the view-controller’s view into an ImageContext and then cutting out the portion that (here: roughly) corresponds to the non-dimmed “window” in the center.
The image is then saved to the phone’s photo gallery.
Here’s the actual cropping code that is executed when you tap the “OK”-button.
Very straightforward stuff.
But as I said, it took me a while. For some reason I never thought of taking a screenshot first.. ;)
Also this solution has the limitation of pixel size. If you want to crop an image of for example 10000 times 10000 pixels and get half of it, you would expect a 5000x5000 pixel result. However, because of the screenshot technique, the cropped area will never be bigger than the pixels on the iPhone screen.
I’ve scrapped the website where I offer setting up your email-server. While it was fun to learn and experiment with, and while some have expressed interest in the offer, it’s neither pracitcal nor profitable for me to continue offering it.
Please refer to this post for information how to start with the email topic yourself. It describes a simple way of setting up an emailserver with Ubuntu.