mpatric.com

iOS

Updated Thu 28 Nov 2013 by Michael Patricios , 10 comments

A while ago I needed to allow users to enter a monetary value into a text input in an iOS app. There seem to be a few approaches to doing this, such as:

  • Use a text field with a full keyboard and validate what the user entered, or only accept numeric input and a period or comma character
  • Use a text field with a numeric keypad, but don't allow minor units (cents/pence) as there is no period or comma character available on this keypad
  • Use spinners

To me, none of these options gives a good user experience; I find the best approach is what many ATMs do, which is to allow you to enter only the digits, but have a fixed decimal separator. So, to enter '123.45' you would type 1-2-3-4-5; to enter '18.00' you would type 1-8-0-0; and so on.

In this post, I am going to do this in iOS with a text input and a numeric keypad. The Objective-C code for this is available on github.

Decimal text input

Posted Sat 02 Nov 2013 by Michael Patricios , 0 comments

If, like me, you have iOS projects that use custom table cells in table views, you may have noticed that when rebuilding the projects for iOS7, table cells are always rendered with a white background, which means if your custom table cells have their own background you may not see it. The solution to this problem can be found in the UITableViewCell Class Reference:

Posted Sat 21 May 2011 by Michael Patricios , 9 comments

When using a Navigation Controller in a Cocoa Touch application, the framework takes care of many things, including generation of a back button when you push a view controller to the navigation controller. The back button gets the same title of the parent view, which a lot of the time is what you might want, but every now and again it's not. For example, in my cool application, the initial view has the title 'My Cool Application' - when you navigate to the settings view, the back button has the long, unwieldy title 'My Cool Application', making the button so big that it pushes the 'Settings' title to the right.

First level navigation view Second level navigation view

Posted Sat 20 Mar 2010 by Michael Patricios , 2 comments

Much time went into making the AI of reversi strong enough on its higher levels to challenge human players. The highest three levels (of the seven available) are challenging for most human players. On the lower levels, the intention was for it to play as a novice human would play. On the lowest level (beginner) in particular it plays for short-term gains, without considering longer term strategy at all. On each turn, the beginner level plays the move that flips as many of the opponent's pieces, taking a corner if one is available and avoiding squares that would give the opponent a corner on the very next move. This reflects the basic manner in which most novices would tend to play reversi.

Posted Wed 22 Apr 2009 by Michael Patricios , 2 comments

Magnetic Block Puzzle is now available on the App Store for a small amount.

It's a departure from my two previous games, Reversi and Merelles, which were both abstract strategy games. Magnetic Block Puzzle is, as the name implies, a puzzle game. The aim of each of the 110 puzzles is to join the coloured blocks, which are special magnets that only stick to other blocks of the same colour, by tilting the puzzle to make the blocks move.

Older postsPage 1 of 2