Tag Archives: iphone

Tutorial: Storyboard in XCode 4.2 with Navigation Controller and Tabbar Controller (Part 2)

Hello again!  If you’re reading this tutorial I’m going to assume that you read part 1 and are ready to continue.  In this tutorial we will take the project from part 1 and expand the second tab (the table) to include some actual table data and a transition to a ‘detail’ screen.  In this instance I’m using movie names and movie images to make it look pretty.  There’s a tiny bit of coding taking place here, but nothing exceptional.  We won’t be making use of Core Data at this stage, just to keep things simple.  Lets get on with it shall we?  (*keep in mind this was written in a hurry, but has been tested!*)

Continue reading

Tutorial: Storyboard in XCode 4.2 with Navigation Controller and Tabbar Controller (Part 1)

Based upon the fact that there are still very few tutorials on how to use the storyboarding stuff in Xcode 4.2 (iOS 5) – I’ve decided to write this second and slightly more complicated tutorial. The output of the tutorial will be an app which uses a tab bar, navigation controllers and a table view controller. It won’t be the most complex of tutorials but should serve to help those who are confused about wiring up a slightly more complex view controller setup. In this part, we will set up the bulk of the work and get some views working. In part 2, we will look at the table side of things.

Before we start, you should download the image pack (below) for the tab bar images I’ll be using. These images are beautifully crafted by Joseph Wain from Glyphish.com. As a side note, Joseph has just released Glyphish Pro 3 which can be purchased from his website for very little money!  It includes 400 icons for iPhone and iPad development that are an absolute must for developers! The images are reused here with permission. Of course, if you’d prefer to have imageless tab bar items then feel free to skip this step (and the image assignment steps later on) but it won’t look as cool!

Continue reading

Supporting orientation changes the easy way!

A couple of days ago I wrote a quick tutorial on how to support multiple orientations in an iPhone app without any stress. Then the more astute of you will have noticed it disappeared. Well, I decided to make my Layout Manager a little more friendly and easy to use. Down at the bottom of this post you’ll find a project with a couple of demo views and the manager itself. It’s very easy to follow. Here’s the back story…

Until recently I’ve only bothered supporting portrait orientation in my iPhone apps. I suspect this was largely driven by a lack of need to support anything else, and partially an inherent laziness which always seems to prevail over my work. Anyway, turns out that sometimes I DO need to support different orientations so I went to work looking for a clean way to do it and arrived at the following solutions….

  1. Create two view controllers and swap them out with a navigation controller.
  2. Programmatically move stuff when the orientation changes.
  3. Run around panicking about the fact you can’t support orientation changes.

In all my searching, I didn’t find an easy way to do it, so I went for option 2 and set about making a nice clean way to get it all to just ‘happen’ without too much effort. Eventually I arrived at the solution that this blog post is all about. Here’s what I did… Continue reading

A basic MapView and annotation tutorial

Map viewI suppose it was inevitable that I’d end up needing to use the Mapkit on iPhone.  For a current project I’ve been required to plot a location on a map so looked at a straight forward way to achieve what I was after.  Thankfully, iPhone makes it very easy to do this.

The following tutorial takes you through creating a project from scratch, which will plot a single point from latitude and longitude coordinates and zoom to that position. Continue reading

Common iPhone sizes, dimensions and other stuff

Measuring the iPhoneLAST UPDATED: 26th Jan, 2011

I can’t count the amount of time I’ve gone fishing around for dimensions and stuff while I’ve been writing code.  Then usually, this distraction leads me to another distraction and before I know it, I’m playing Black Ops online.  This (lack of) productivity won’t stand, man!   So here for your convenience is a collection of measurements and stuff for the iPhone. I’ve included the high res versions of the measurements too (for the retina display on iPhone 4) Continue reading

Cropping a UIImage on iPhone

As part of a larger project, I was faced with the mini challenge of cropping a UIImage. Seems like a straightforward thing to do (and in fact, it was when I’d finished looking into various ways of doing it).

My requirement was to take an existing UIImage and crop off the top section of the image. To the left, you should see a poor diagram of the crop I wanted to make.  The green area (the full size of the image) is my original image, weighing in at 320 pixels by 480 pixels.  The red area is the area I wanted to be left with, which was to be 320 pixels by 430 pixels (a cutting of 50 pixels off the top!). Lets do it! Continue reading

Too bright or not too bright?

I thought I may was well mention this in a very very short post because I took a lot of time out to search for answers. As we all know, there are certain APIs which Apple don’t allow the use of which include some of the more useful features on the iPhone. A couple of days ago, I was looking into controlling brightness and guess what? You can’t do it. Not with the public APIs anyway.

But I wanted to find out if it were possible with any third party APIs and really couldn’t find anything. Yeah, it seems to be ‘that’ simple. I did see reference to using the following code in a couple of websites – but I assure you, this doesn’t seem to work (not in iOS 4.x anyway). Continue reading

iPhone & Mac – the Marmite of electronics

Marmite - you love it or hate itIs it just me, or do iPhone users around the world find themselves in an inevitable argument about iPhone versus ANY other smartphone? Or Mac users find themselves under fire from PC users? It seems that Apple products are the Marmite of the computing world.

It always starts the same with a general discussion about technology. Then I drop in that I love my phone (or Mac) which always prompts the question “what’s so good about it?”. This is where the problems start because as everyone knows, there is no right answer! Of course, that doesn’t stop me listing all the things which I love about Mac or iPhone – nor does it seem to stop the other person listing the (usually few but repetative) things they hate. But where does it stop? A friend of mine brandished me an ‘iPhone evangelist’ on Facebook the other day because I counter-posted against someone who was slating the product. I did manage to see a certain irony behind that however. The more I speak about the products I love, the more people want to crush that belief. Does this make them anti-iphone evangelists?

The day that other manufacturers start making products which I find as intuitive and beautiful – I’ll perhaps give in and buy something else. But while the world of electronics follows in the wake of the inventive trail being set ablaze by Apple…. I think I’ll stay right where I am and be proud to speak up ‘as and when’ the need arises. In your face, rival products!

Review – Learning iOS Game Programming

For me – the biggest stumbling block in iPhone development was how games programming worked with object oriented programming (OOP). For some reason, my brain couldn’t make the jump from procedural programmingLearning iOS Game Programming to this new way of thinking which in turn made game programming very hard. I’ve bought a whole bunch of iPhone related books in the last two years, which included the obvious world-renowned ones such as Programming in Objective-C (Stephen Kochan) and Cocoa(R) Programming for Mac(R) OS X (Aaron Hillegass) and some more obscure books. But I was still missing the crucial part of knowledge – how games all hung together in iOS.

So while searching the web I found lots of interesting articles and sites which were dedicated to this cause. Amongst them, I discovered 71Squared.com which housed a number of tutorials on building a game from the point of a non-professional developer. I loved it – just the kind of thing I was looking for, though never found the time to actually finish the tutorials. Anyway, to cut a long story short – Michael Daly then released a book presumably related to those articles called Learning iOS Game Programming, which I immediately bought and started working through. Continue reading

Making a count indicator

Count indicator exampleJust recently I wrote a list app for iPhone, so I could maintain lists with items in them.  I wanted to jazz it up a bit by using a count indicator similar to the one you see in the mail app, which shows you how many messages you’ve had from someone (you know the one… the little bubble with a number in it).  Anyway, turns out that Apple don’t provide a mechanism for this so I wrote my own one.  You can see it over there to the left (a little gray bubble with a count in it) and this post basically shows you how I achieved it (with code and an example project).

All it’s essentially doing is using Core Graphics to draw a line. That’s all. One line, except to get the rounded ends I’m using a cap as demonstrated in many of the Apple examples. I thought this was easier than figuring out how to round it off manually. Then I take the text and paste it as close to center as I can.

Now it’s not perfect I know… changing the font size doesn’t always vertically align the number properly – but it does look nice enough, and I’m sure someone can make use of this even if a little tweaking is required.  At around 14 point font size it looks good….

Continue reading