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 Sun 06 Feb 2011 by Michael Patricios , 3 comments

I stumbled upon this reversi game, Deep Green Reversi, which runs on Android. The graphics in the game, in particular the status bar under the board and the menus look very similar to Reversi on the iPhone. Furthermore, the game description for Deep Green on the Android market is an almost verbatim copy of the description for Reversi on the App Store, with 'iPhone' replaced by 'Android'.

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.

Older postsPage 1 of 2