Category: iOS Toggle Comment Threads | Keyboard Shortcuts

These posts are syndicated from my iOS Dev Diary over at

The format is slightly different with more code snippets and less explanations. I had originally designed it as a notebook in iOS Development – now you can follow along if you’re interested.

  • Jay Versluis 1:02 pm on December 29, 2014 Permalink | Reply
    Tags: , GMX,   

    Categories: iOS ( 220 )

    How to override auto-detected Email Settings in iOS 


    The nature of any automation is that sometimes it just doesn’t work. Apple’s iOS is no exception.

    When you add a new email account on your iOS device, several mail providers’ settings can be auto detected. It’s there to make our lives easier so that we don’t have to add details for mail servers and ports manually. Yahoo Mail and Gmail are detected perfectly, but other services – for example GMX – are not.

    This is no problem if iOS simply says that you need to add details manually (as with Plesk mail), but it is an issue if iOS has detected the correct POP settings and you’d much rather use IMAP. iOS offers no way to change these settings when auto detection was successful.

    There’s a trick which will let you specify your own settings by bodging your password. Do the following:

    • under Settings – Mail, Contacts, Calendars – add a new account
    • choose other, then select Add Mail Account
    • This will show you a dialogue similar to the one in the screenshot above. Fill out your details but deliberately choose the wrong password. A single letter of your choice will do.
    • Hit Next and the auto-detection goes to work, telling you the password was wrong.
    • Now configure the settings to your liking, including a choice of POP and IMAP, incoming and outgoing mail servers, encryption options and ports.

    I found this out by helping my friend Oliver leave POP behind for good on his new iPhone 6. In case you need the GMX IMAP details, they can be found here:

  • Jay Versluis 11:46 am on August 4, 2014 Permalink | Reply

    Categories: iOS, Screencast ( 220 )

    Core Data Nugget #1: How to speak Core Data 

    In this screencast I’ll talk you through the lingo of Core Data: those scary classes and expressions that you’ll frequently come across. In fact, this is the start of a new series:

    Core Data Nuggets are bite-sized chunks about the framework. Dip in and out or watch them all in a row and learn how this super complicated framework works and what it has to offer.

    Don’t get overwhelmed by Core Data: it wants to help – it’s just not designed with humans in mind.

    As always, enjoy!

  • Jay Versluis 9:28 am on July 21, 2014 Permalink | Reply  
    Categories: iOS, Screencast ( 220 )

    Creating In-App Purchases in iOS 7 

    In this 7-part series I’ll show you how to create an In-App Purchase in iOS 7 with Xcode 5.1. The course will run you through everything from setting up your product in iTunes Connect, creating a custom shop class for easy re-use, making “first contact” with the App Store and how to deal with its responses.

    These are Parts 1+2 which are free to watch. You can see the rest of the course here:

  • Jay Versluis 8:51 am on July 14, 2014 Permalink | Reply  
    Categories: iOS, Screencast ( 220 )

    How to use a Popover on iPad 

    In this series I’ll show you how to create Popovers on iPad. They’re fairly easy to create once you get the hang of the inner workings of the UIPopoverController.

    I’ll show you how to create basic Popover in code and in your Storyboard, and we’ll discuss how you can retrieve data from a Popover when it’s dismissed. We’ll do this with a simple UIDatePicker. In the last video I’ll demonstrate how you can pick images from the camera roll using the UImagePickerController with a Popover – which is how you’re meant to do it on iPad.

    The series contains three videos in total. The first one is “free to air”, and the other two are for members only.

    You can watch the whole course here:

  • Jay Versluis 6:18 am on July 7, 2014 Permalink | Reply
    Tags: iPad, UIStoryboard,   

    Categories: iOS, Screencast ( 220 )

    How to change a UIStoryboard from iPhone to iPad in Xcode 5 

    In this screencast I’ll show you how to make an iPhone storyboard display as an iPad storyboard in Xcode 5.1’s Interface Builder. Under the hood a UIStoryboard is just an XML file, and with a small tweak we can make Xcode display it like an iPad or an iPhone. This is a good strategy if you’d like to use your iPhone storyboard as a starting point for an iPad version.

    You can read my full article on my iOS Dev Diary:

  • Jay Versluis 6:16 am on June 30, 2014 Permalink | Reply
    Tags: ,   

    Categories: iOS, Screencast ( 220 )

    How to use iCloud in your iOS App 

    In this series I’ll show you how to use iCloud in your iOS apps. We’ll discuss how to setup Xcode and your app, including App ID and Provisioning Profiles and I’ll demonstrate how to use all three flavours of iCloud: Key Value Storage, Document Storage and iCloud with Core Data.

    The rest of this series is for members of my iOS Dev Diary only – you can watch it here:


  • Jay Versluis 2:17 pm on April 14, 2014 Permalink | Reply  
    Categories: iOS, Screencast ( 220 )

    Creating a Searchable Table View in iOS 

    Xcode_iconIn this 6-part series I’ll show you how to create a searchable UITableView in an iOS App. We’ll start with a standard single view application template in Xcode, create a table view with dummy data, and finally make it searchable.

    This course demonstrates how to do this with Xcode 5.1 and iOS 7.1. We’ll also make the app compatible to for in iOS 6.

    These are the first two parts which are available for free. The rest of the course is only viewable by members of my iOS Dev Diary at

    You can get the source code and follow along here:



  • Jay Versluis 4:01 pm on December 31, 2013 Permalink | Reply  
    Categories: iOS ( 220 )

    How to display a “spinning wheel” indicator in the centre of your screen 

    Screen Shot 2013-12-31 at 15.58.02Sometimes you want to tell the user that something’s happening behind the scenes and that there’s no need to panic. While your process is happening you can display a “spinning gear” in the middle of your screen.

    One way of doing this is via a UIActivityIndicatorView.

    You can create them in Interface Builder, but it’s very easy to create one and show it if and when necessary. Here’s how:

    - (UIActivityIndicatorView *)indicator {
        if (!_indicator) {
            _indicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
        return _indicator;
    - (void)viewDidLoad
        [super viewDidLoad];
        [self.view addSubview:self.indicator];

    This creates it in the centre of your UI, but it’s invisible until switched on like so:

    // to start spinning
    [self.indicator startAnimating];
    // and to stop it again
    [self.indicator stopAnimating];

    The UIActivityIndicatorView has a property that automatically hides it when stopped, so all we have to worry about is starting and stopping it when necessary.

  • Jay Versluis 9:00 am on December 31, 2013 Permalink | Reply  
    Categories: iOS ( 220 )

    How to load a different storyboard depending on screen size in iOS 

    As much as I appreciate the idea of Auto Layout, I don’t think it likes me very much. In turn, I don’t like Auto Layout very much. The pain and hassle it takes to make several UI elements fit well on a 4 inch screen as well as a 3.5 inch screen regularly drives me crazy. On paper it’s a great idea – but in reality not fit for prime time.

    Screen Shot 2013-12-31 at 08.56.22

    It’s not a coincidence that we can choose completely different storyboards for iPads and iPhones. Let’s take the same approach when dealing with the two different iPhone screen sizes by loading different storyboards.

    Here’s how: First, finish one version of your storyboard. Next select it and head over to File – Duplicate. Give the second one an appropriate name, then tweak your UI elements so that they look nice on the other screen size.

    Now add this to your AppDelegate.m:

    - (UIStoryboard *)grabStoryboard {
        UIStoryboard *storyboard;
        // detect the height of our screen
        int height = [UIScreen mainScreen].bounds.size.height;
        if (height == 480) {
            storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            // NSLog(@"Device has a 3.5inch Display.");
        } else {
            storyboard = [UIStoryboard storyboardWithName:@"Main-4in" bundle:nil];
            // NSLog(@"Device has a 4inch Display.");
        return storyboard;

    This method returns the following UIStoryboard file:

    • Main.storyboard on 3.5inch devices
    • Main-4in.storyboard on 4inch devices

    Now we need to make sure it gets loaded appropriately. We’ll take care of it in AppDelegate.m like so:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
        UIStoryboard *storyboard = [self grabStoryboard];
        // show the storyboard
        self.window.rootViewController = [storyboard instantiateInitialViewController];
        [self.window makeKeyAndVisible];
        return YES;

    This overrides the default storyboard that’s declared in your project settings. You can expand the above method by checking which iOS Version the device is running, and of course returning an iPad storyboard too.

    In your face, “Auto Layout”!

    • Charles Miller 2:23 pm on June 26, 2014 Permalink | Reply

      I am doing this with iOS7 and it seems to work fine with my iPhone 5 but not with my iPhone 4s. Any suggestions?

      • Jay Versluis 9:28 am on June 27, 2014 Permalink | Reply

        Are both phones starting in portrait mode? The height parameter might be reported as the shorter side of the iPhone and hence the pixel check would fail, regardless of the tallness of the screen. Just a thought, I’ve not checked this myself yet but it’s worth looking into.

  • Jay Versluis 6:03 am on December 31, 2013 Permalink | Reply  
    Categories: iOS ( 220 )

    How to dismiss the iOS Keyboard when the done button is pressed 

    It has puzzled many generations how to get rid of the keyboard when the user is done entering text into an iOS text field. There doesn’t seem to be an obvious action we can attach to make this happen.

    iOS Simulator Screen shot 31 Dec 2013 05.45.27

    That’s because rather than looking at the keyboard itself, we need to look at what actually brought it up in the first place: the UITextField. Even though the text field can trigger an action, we don’t want to touch that for dismissing the keyboard. All we need to do is to implement the following method from its delegate protocol:

    - (BOOL)textFieldShouldReturn:(UITextField *)textField {
        // done button was pressed - dismiss keyboard
        [textField resignFirstResponder];
        return YES;

    This method is called whenever the return button is pressed. We return YES to agree, and resign the text field’s first responder status which takes the user focus away from it.

    Since this is a protocol we *should* really conform to it formally by declaring it in the header file. It appears to work without this step, but let’s play it by the rules here:

    @interface ViewController : UIViewController <UITextFieldDelegate>

    Note that you need to connect your text field’s delegate in Interface Builder to the class that’s implementing the above method (i.e. self), otherwise the keyboard won’t be dismissed. To do this, control-drag from the text field to the orange square at the bottom of your view controller and select “delegate”. You can verify this in the connections inspector:

    Screen Shot 2013-12-31 at 05.55.36

    • Josh 10:03 pm on May 8, 2014 Permalink | Reply

      I followed these exact steps and still the keyboard will not be dismissed. I’m using xcode 5.1.1.

      • Jay Versluis 1:15 pm on May 9, 2014 Permalink | Reply

        Hi Josh,

        it’s easy to overlook a step. Check out my screencast which demonstrates how this works in detail, also using Xcode 5.1.1:

        • Josh 4:08 pm on May 9, 2014 Permalink | Reply

          I just watched the video and looking forward to trying it out when I get home. Just as an aside, I noticed that when I select the text field for the purpose of assigning a delegate, the selected text field is highlighted pink, not blue like in your video. I’m not sure if this is a clue leading to the source of my problem, but I thought I’d mention it anyway. Thanks for the video!

          • Jay Versluis 4:18 pm on May 9, 2014 Permalink

            Great, glad you like it! Pink is strange indeed – I can’t make Xcode show anything in pink. Let me know what you find out, it’s intriguing 😉

    • Josh 9:28 am on May 10, 2014 Permalink | Reply

      Good news. I followed along with your video and it worked! I then went back to my code that wasn’t working. I think the problem was that I didn’t wait for the view controller to be highlighted when assigning it as delegate for the text field. After doing that, the keyboard successfully dismissed. Thanks for your help!

      • Jay Versluis 2:48 pm on May 10, 2014 Permalink | Reply

        Excellent news – great to hear you got it working. Happy coding!

compose new post
next post/next comment
previous post/previous comment
show/hide comments
go to top
go to login
show/hide help
shift + esc