Tag Archives: iphone

Detect iPhone / iTouch Orientation – Change In Your Code

I have been working on a template for an iPhone Library Application today, its pretty simple stuff, A search, Asynchonous paginated results with the full details on each result. It will be using FileMaker for its database, but currently I am searching a large PHP array for testing.

When displaying the full result, when your phone is help upright, the results look good, but when you roll the phone over, the display is crap so after a fair amount of googling and multiple sources linking to Apple, and a missing page http://developer.apple.com/samplecode/iPhoneOrientation/index.html I found this post @ DevPhone.com.

Its exactly what I wanted. If you need an iPhone/iPod touch Application or web application, contact me via iPhone Web Application @ www.webapp.co.nz.

window.onorientationchange = function() {
  /*window.orientation returns a value that indicates whether iPhone is in portrait mode, landscape mode with the screen turned to the
    left, or landscape mode with the screen turned to the right. */
  var orientation = window.orientation;
  switch(orientation) {

    case 0:
        /* If in portrait mode, sets the body's class attribute to portrait. Consequently, all style definitions matching the body[class="portrait"] declaration
           in the iPhoneOrientation.css file will be selected and used to style "Handling iPhone or iPod touch Orientation Events". */
        document.body.setAttribute("class","portrait");

        /* Add a descriptive message on "Handling iPhone or iPod touch Orientation Events"  */
        document.getElementById("currentOrientation").innerHTML="Now in portrait orientation (Home button on the bottom).";
        break;

    case 90:
        /* If in landscape mode with the screen turned to the left, sets the body's class attribute to landscapeLeft. In this case, all style definitions matching the
           body[class="landscapeLeft"] declaration in the iPhoneOrientation.css file will be selected and used to style "Handling iPhone or iPod touch Orientation Events". */
        document.body.setAttribute("class","landscapeLeft");

        document.getElementById("currentOrientation").innerHTML="Now in landscape orientation and turned to the left (Home button to the right).";
        break;

    case -90:
        /* If in landscape mode with the screen turned to the right, sets the body's class attribute to landscapeRight. Here, all style definitions matching the
           body[class="landscapeRight"] declaration in the iPhoneOrientation.css file will be selected and used to style "Handling iPhone or iPod touch Orientation Events". */
        document.body.setAttribute("class","landscapeRight");

        document.getElementById("currentOrientation").innerHTML="Now in landscape orientation and turned to the right (Home button to the left).";
        break;
  }
}

WPTouch – iPhone your WordPress

I came accross this sweet WordPress Plugin called ‘WPTouch today and have just installed it on this blog.

What it does, is create an iPhone friendly version of your blog. It has some sweet customisable features, like using Advanced jQuery Javascript Effects (ajax entries, ajax comments, smooth effects), Enable Gravatars in Comments.

When Advanced Javascript Is Disabled:

Your site loads faster on EDGE and 3G connections
Ajax & jQuery are not loaded & used for comments, entries, excerpts etc.
*Fixes javascript conflict issues where the WPtouch menu drop-down doesn’t work
When Gravatars Are Disabled:

Gravatar.com images are not shown beside commenter’s names
As a result, single post pages load faster on EDGE and 3G connections

It also allows for some customisation in how your blog is presented ( Icons, titles, Colours ).
Try it out on your iPhone or iPod touch, and if you are reading this from your iPhone already, then how do you like it ?

iPhone Ringtones

With the Apple iPhone, Apple have reduced the availability of the end user to easily add free custom ringtones. You have the standard tones, and the 30 second snippets from the Apple Store, but you have no control on where the snippets start and stop.

I started looking in to how I could generate my own ringtones and add them.

I first found and downloaded ‘Audacity and started to hack in to a mp3 song from my iTunes library.

When looking around to find the best format to export the new ringtone snippet (which is ‘.m4r’), I came across ‘Audiko‘.

Adiuko.Net is a fantastic FREE site that has 1000′s of pre-existing ring tones in multiple formats.

The other great feature is that you can upload your own mp3 file, select your own track snippet, and it will create a ringtone that you and any one else can now download.

The service is a great idea, the server speed is great.

Check out Audiko!