background preloader

iPhone Programming Tutorial

iPhone Programming Tutorial

BackImage 4 Navigation Updated 2012/03/05: I have found a better way to solve this problem without method swizzling. Please take a look at my post titled Subclassing Those Hard-to-Reach Classes as well as my ExampleNavBarBackground project which uses this new technique. Updated 2011/10/18: As of iOS 5, Apple has officially added support for setting background images in UINavigationBars. To do this, all you need to do is execute the setBackgroundImage:forBarMetrics: method of UINavigationBar. UINavigationBar *navBar = [[self navigationController] navigationBar];UIImage *backgroundImage = [UIImage imageNamed:@"nav-bar-background-normal"];[navBar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault]; However, if you want to support both iOS 4 and iOS 5, you will need to conditionally call the code above on iOS 5 and the code I describe below in iOS 4. Toward the end of the development phase for the first release of Epicure, Adam Betts started sending me stellar design mockups. SCAppUtils.h Phew.

How to make a Pull-To-Reload TableView just like Tweetie 2 @ Dr. Touch When I started on Twitter, I tried out a few Twitter clients both on Mac and iPhone until I quickly settled on Tweetie. When Loren Brichter made the bold move to sell Tweetie 2 as a seperate app I also purchased it because I am convinced this guy means quality and Tweetie 2 is on the first page of my springboard. One thing that’s cool about Tweetie 2 is the fresh paradigm to refreshing the contents of a table view. Loren recognized this need and innovated the Pull-To-Reload paradigm. Might be a good case to make this the standard way from now on because it feels more logical and natural than to tap on a small button with a circular arrow on it. At first I experimented a bit myself and found that if you add a subview to a tableview then this moves together with it. So thank you to Devin for laying the groundwork. The second piece of the puzzle is how to make the refresh view stay visible during reloading. Devin’s implementation consists of two classes. EGORefreshTableHeaderView.h

Changing Tint / Background color of UITabBar The Exciter - Touches and UIScrollView inside a UITableView Sunday December 28, 2008 UPDATE: please don’t don’t do it like this, it was only needed on iPhoneOS 2.×. A lot have changed in iOS since then and you can now do it properly "Trafikanten" for the iPhone is the iPhone incarnation of the betabrite-style signs hanging around Oslo, providing travellers with real-time departure information on busses, trams and subways. So incorporating some of that feeling into the application, while still maintaining that iPhone look n’ feel was a crucial UI design issue for us. A betabrite sign is basically a set of LED lamps that turn on and off in sequences, usually to portray text scrolling across the screen. The thing is, a UITableView takes completely control of the responder chain (and therefore touches) so that it can try and figure out if the user intents to scroll the scrollview, as described in the documentation overview for the UIScrollView class. Please observe this artist rendition of the view hierarchy: So that takes care of that right?

Resize a UIImage the right way — Trevor’s Bike Shed When deadlines loom, even skilled and experienced programmers can get a little sloppy. The pressure to ship may cause them to cut corners and look for a quick and easy solution, even if that solution is sure to cause trouble later on. Eventually, their coding style devolves into copy and paste programming, a lamentable tactic that involves cherry-picking snippets of code from a past project and putting them to use in the current one. Of course, the proper solution is to factor out the code into some kind of reusable library, but due to time constraints, it’s simply duplicated wherever it’s needed. Any bugs in the original code have now spread to a dozen different places in a dozen different projects. Yet in the world of iPhone applications, copy and paste programming seems to be disturbingly common. This situation has transformed more than a few iPhone programmers into copy and paste programmers. Now imagine what happens when a thousand iPhone developers find the same snippet. License

Related: