Detecting Apple Device Orientation

Following on from my post at the weekend about Responsive Design, a fellow blogger Tristan Bettany has emailed in his example for detecting either the iPad or the iPhone and the screen orientation.

It uses a small amount of PHP to detect the device then CSS to detect the orientation. Copy and paste the following into the head of your page.

<?php
//Functions to check user agent for iPad, iPod, iPhone
function iPadCheck(){
return preg_match('/(iPad)/', $_SERVER['HTTP_USER_AGENT']);
}
function iPhoneCheck(){
return preg_match('/(iPhone|iPod)/', $_SERVER['HTTP_USER_AGENT']);
}

//Set correct css files based on detected device
//orientation property supported in mobile safari to change layout on rotation
if (iPadCheck()) {
echo'
<link rel="stylesheet" type="text/css" media="screen and (orientation:portrait)" href="iPadPortrait.css" />
<link rel="stylesheet" type="text/css" media="screen and (orientation:landscape)" href="iPadLandscape.css" />
';
} else if (iPhoneCheck()) {
echo'
<link rel="stylesheet" type="text/css" media="screen and (orientation:portrait)" href="iPhonePortrait.css" />
<link rel="stylesheet" type="text/css" media="screen and (orientation:landscape)" href="iPhoneLandscape.css" />
';
} else {
echo'
<link rel="stylesheet" type="text/css" media="screen and (max-width: 1199px)" href="minDesktop.css" />
<link rel="stylesheet" type="text/css" media="screen and (min-width: 1200px)" href="fullDesktop.css" />
';
}
?>

The script detects the device then includes the associated stylesheet depending on the orientation.

Any questions add a comment.

Top iPad News Apps

Here are my top iPad news apps:

Reuters News Pro

An overall great app for finding out today's news articles, pictures, videos and financial data. Homepage articles can be scrolled horizontally whilst vertical scrolling shows news categories. Images and text in articles can be enlarged.

Eurosport

Great for live sport, latest scores, breaking news and articles - no other sports app has content updated as often as the Eurosport app.

BBC News

Similar to the Reuters app in content, the BBC News app shows the recent articles on the left (in horizontal mode) and at the top (in vertical mode) allowing you to easily browse through articles.

Mashable

Best app for social media/technology news. I like how the articles appear over the headlines through i do find myself knocking the previous and next buttons by accident.

Bloomberg

Great for in depth financial news and data. The app also lets you keep a portfolio of the shares you own.

The Financial Times

The FT app is more article based than the Bloomberg app but has some nice features including being able to horizontal scroll between articles.

The Guardian Eyewitness

A great app for viewing current photos on the iPad, I like how with each picture it tells you a little about how the photographer got the shot.

Reuters Galleries

Again another nice photo based application, I like how photos can be displayed as a slide show.

Bonus App: AccuWeather

Not strictly a news app but a great app for finding out the weather.

Know any other great news apps? If so share them below!

iMac History Website

A new website has been created detailing all models from the past eleven years of the iconic Apple desktop computer. iMac History has been created as a testament to the success and status of the Apple iMac in society.

iMac History recognises the importance of how the iMac changed the landscape of the personal computer market and helped Apple regain its status as a global technology leader.

The website orders models by date, processor type and is fully searchable for keywords specific to certain models. Users are invited to share their comments and experiences to each iMac.

Having previously developed and sold a similar website on the history of the iPod the creators have worked hard researching past models, sourcing images and finding related adverts and videos.

www.iMacHistory.com officially launched on April 1st 2010.

Time Machine Saves the Day

On Sunday disaster struck, my hard drive corrupted and OS X wouldn't boot. I feared the worst but had been backing up for the past two years using OS X Time Machine. Could it be as simple as restoring from backup to a new drive?

My first job was to install a new hard drive, this is easier said then done in the all in one iMac. Fortunately this video from camodesto went through step by step, first removing the glass front, then the aluminium case and then the screen. Finally you can replace the hard drive, I opted for an upgrade to a 1TB drive.

After booting from the Snow Leopard DVD I created a partition on the new hard drive then restored from Time Machine. The process took around seven hours to copy my 300gig of data from the External drive.

When I rebooted my Mac had been restored to 5pm on Sunday, 90mins before it had died. All my files were restored, even my Firefox tabs were saved.

iPhone 3GS

On Friday I received my iPhone 3GS fresh from O2. I've had my 2G for around a year now and with my Tmobile contract expired it was the perfect time to upgrade.

Aesthetically there is not a big difference between the 3G and 3GS however the phone is a lot quicker compared to the 2G, applications load quicker, text messages and emails load instantly and moving around the interface seems a lot more smooth.

Simcity was the most power hungry application I had on my 2G and it took a mean 34 seconds to open, on the 3GS it takes a more reasonable 17 seconds making the 3GS twice as quick.

The camera is a small improvement and works slightly better in low light but is still one of the iPhones weaknesses. The upload to YouTube feature is a nice touch however I've yet to find something interesting enough to upload. 

The majority of other improvements come in the 3.0 software (rather than updated hardware) with the wide keyboard on text messaging being one of the best improvements. Copy and paste works well though is a bit fiddly. Being able to buy music, videos and apps over 3G will hurt the bank balance I'm sure.

iPhoto 09 (version 8) Review - Faces

Apple's home multimedia suite iLife was recently upgraded, while all apps (iMovie, iWeb, iDVD, iPhoto and Garageband) got an upgrade iPhoto got the best and most significant new features. The most useful of these is Faces.

Faces

For a long time now you have been able to tag people on social networking sites such as Facebook linking them to their user profile. Facebook has the ability to detect faces however cannot match them meaning you have to tag every person in every photo. iPhoto takes this to the next level, after first scanning your entire library to detect faces (a job which took around 90mins on my 8418 photos on my 2.4ghz C2D Intel iMac) you have the ability to start tagging people.

iPhoto 09

Above: iPhoto scanning my library looking for sexy people

Once you have tagged a person in a couple of photos iPhoto will start to suggest similar photos, at first some of the suggestions are wild guesses but by simply clicking a photo once to accept or double clicking a photo to deny makes it very quick and easy to work through your library.

iPhoto 08

Above: Single click to accept a picture, double click to deny.

The majority of my photos contain people, often from nights out in fancy dress. iPhoto struggled with some of these photo at first and I found myself having to tag photos so that iPhoto could detect the rest.

Changing Pete iPhoto

Above: After a couple hours of tagging I now had a selection of Pete photos. I had to tag myself on numerous occassions, iPhoto could not automatically detect that baby Pete (top right) was the same as sumo Pete (bottom middle).

Friends

Above: I now have my three friends tagged in iPhoto.

Tagging photos is all very good but its what you then do with these photos that is interesting. For instance what if I want to see all the pictures of me and a friend or with valentines day approaching all the photos of Laura and myself. I can create a smart album, just as you would in the older versions of iPhoto but this time you have the option of specifying names.

Pete and Laura Filter

Above: A filter in a smart album.

Pete and Laura Gallery

Above: The filter results of pictures of Laura and myself.

It doesn't end here as iPhoto then lets you print or order items based on those photos producing an instant valentines day present.

Above: Three years worth of presents.

With iPhoto 09 you also have the option for automatically uploading photos to Facebook and Flickr.

Tagging takes several hours especially if you have a large library but its well worth it.


Syndicate content