Tag Archives: IOS

Centering an image in IOS

Just been struggling to update flagSter to support the new iPhone5 screen. Issue was horizontally centering the flag image when in landscape mode. This was because the screen width varies between iPhone and iPhone5 when in that orientation.

Quickest/easiest method was discovered, wherelse, in Stack Overflow. Thanks Damo.

CGPoint center = myImage.center;
center.x = self.view.center.x;
myImage.center = center;

Best part of this solution, other than its simplicity, is it is not that difficult to determine how you could possible sort out the vertical orientation too!

Removing columns from SQLite Databases

For a while I’d been annoyed that my SQLite database for Flagster contained a few dead-end columns. Since SQLite does not allow you to drop columns, I was resigned to having them gathering dust, and space.

However searching for unrelated help, came across a neat trick for removing columns. Although it takes three stages.

This was all tested/completed using Base, arguably the best SQLite editor on the Mac. Make sure you take a backup before starting though, just in case.

(1) duplicate table (without the unwanted columns) as a new table in your database

To create a new table from an old one, use a combination of CREATE and SELECT commands:

  SELECT col1, col2, col3, col4 FROM oldTable;

Just only list the columns you want in the SELECT statement, and list them in the order you want them in the table. For bonus points you can also sort the records as they’re written to the table.

  SELECT col1, col2, col3, col4 FROM oldTable
  SORT BY col2;

(2) drop the old table (with the unwanted columns)

Once confident your newTable has all the data you need, you can remove the old one. This is simple using the DROP command:

DROP TABLE oldTable;

(3) rename the new table with the old name

Finally, to tidy up and save updating any existing code, rename the new table to match the old table name:

  RENAME TO oldTable;

And that’s it. Three steps later you’ve cleaned up your database, sorted your records, and made everything right in the world.

Want your iPad calendar to start the week on Monday? Move to Namibia

Frustratingly, my iPad calendar appeared to unilaterally decide that the first day of the week was Sunday. And there was no obvious setting to change it, like there is for Calendar on the Mac.

Turns out this “feature” is decided by Apple based on your region. They believe Australian weeks start on Sunday so that’s the way it is. To change the day, change your region.

For Australians wanting their calendar to start on a Monday:

  1. Launch settings
  2. Select General > International
  3. change region format to Namibia

This bizarre choice seems to have the best option for calendar setting, as well as changes it makes to keyboards (what currency symbol you see), date and time formats, even which google you default to when you search. Namibia appears to leave all the other settings “just like Australia”, and still default to google.com.au for searching in Safari.

Thanks to the clever chaps on the Whirlpool forums, particularly dokh22, for uncovering this. Now how long before Apple gives us a calendar setting to do it properly?

Simple image (frame-by-frame) animation in IOS and Xcode

Adding frame-by-frame animations to your iOS application is simple once you find out that a UIImageView can be initialised with an array of images, not just one image.

This post was inspired by a colleague who had not uncovered that fact, and so had spent time arduously linking separate views with timers. This post shows how to use a single view and 3 lines of animation code to do all the work.

What to do?

What we’ll do as a test is animate the blinking eyes on a tennis-playing ninja splash screen. To trigger the animation will add a “blink” button on the same screen.

Don’t ask how we ended up with that as the example (thanks to the friend). But you can download the entire project, or just the images if wanting to join in.
Continue reading

IOS5 – Wireless sync is the gravy

Finally managed to download and install the IOS5 update for the iPad. Most of the new features are unobtrusive, although still trying to find some of them.

However what wins is the wireless synchronisation feature. Now I can update my library (songs, books, tv) on my computer and click Sync. And the iPad gets updated while not connected. While not even switched on. While in my briefcase in another room.


[Although I'll admit it's probably sweet because Apple kept us tethered for far too long!]