Thursday, May 5, 2011

Backup iPhone Pictures – Mac Tips

Listen to this episode
When you have problems with your iPhone, you may have no other choice than to RESTORE it back to the factory state. Before you restore, iTunes says it is making a backup of your phone. However, it isn’t making a backup of any photos you have taken with it. So when the phone is restored, all of your photos will be gone. The good news is that If you have your iPhone set to sync your photos with iPhoto automatically when you plug it in, you may be OK. However, if you are like me and choose for the iPhone not to launch iPhoto when you connect it… well, you need to backup those pics.

How to do it:

1. Plug-in your iPhone and launch iPhoto. iPhoto will detect your iPhone, and you can now choose to import all or import selected pictures.
mactips_358_1.png
Doing this will add pictures you have taken with your iPhone into your iPhoto library.

Another Way – Image Capture

You can also use Image Captureimagecapture.png to do the same thing, but not add them to your iPhoto library.
1. Plug-in your iPhone. Launch Image Capture. You can find it in your Applications folder. If you don’t see it there, look in the Utilities folder. Note: On the podcast, I said it will be in the utilities folder… I forgot that it may reside in Applications.
2. Now it will detect your iPhone, and you can choose to Download Some or Download ALL to your Mac.
mactips_358_2.png

ScrollView example for TextField in iPhone

In the application when user input in the textfield then see UITextField is hidden under the keyboard.This problem solved using the ScrollView. So let see how it will be worked.
In this application we will see how to ScrollView worked in our application. This is the very simple application. In the application when user input in the textfield then see UITextField is hidden under the keyboard.This problem solved using the ScrollView. So let see how it will be worked.

Step 1: Create a View base application using the template. Give the application name “ScrollViewExample”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: Expand classes and notice Interface Builder created the ScrollViewExampleViewController class for you. Expand Resources and notice the template generated a separate nib, ScrollViewExampleViewController.xib, for the “ScrollViewExample”.

Step 4: Open the ScrollViewExampleViewController.h file, we have added scrollview for scrolling the view,and two textfield for display the textbox. So make the following changes in the file:

#import
@interface ScrollViewExampleViewController : UIViewController {

IBOutlet UIScrollView *scrollview;
IBOutlet UITextField *textField1;
IBOutlet UITextField *textField2;

BOOL displayKeyboard;
CGPoint  offset;
UITextField *Field;
}

@property(nonatomic,retain) IBOutlet UIScrollView *scrollview;
@property(nonatomic,retain) IBOutlet UITextField *textField1;
@property(nonatomic,retain) IBOutlet UITextField *textField2;
 

Step 5: Double click your ScrollViewExampleViewController.xib file open it to the Interface Builder. First drag Scroll View from the library and place it to the view window and drag two TextField also, place it to the view window(See the figure below).Connect the File’s Owner icon to the View icon and select view. Select File’s Owner icon to the view and select scrollview. Next drag from the File’s Owner icon to the first textfield and select textfield1, do it once more time for the textfield2. Now save it, close it and go back to the Xcode.



Step 6: In the ScrollViewExampleViewController.m file make the following changes:

- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];

[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector
(keyboardDidShow:)
name: UIKeyboardDidShowNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector
(keyboardDidHide:) name:
UIKeyboardDidHideNotification
object:nil];

scrollview.contentSize = CGSizeMake(SCROLLVIEW_CONTENT_WIDTH,
SCROLLVIEW_CONTENT_HEIGHT);
displayKeyboard = NO;
}

-(void) viewWillDisappear:(BOOL)animated {
[[NSNotificationCenter defaultCenter]
removeObserver:self];
}

-(void) keyboardDidShow: (NSNotification *)notif {
if (displayKeyboard) {
return;
}

NSDictionary* info = [notif userInfo];
NSValue* aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey];
CGSize keyboardSize = [aValue CGRectValue].size;

offset = scrollview.contentOffset;

CGRect viewFrame = scrollview.frame;
viewFrame.size.height -= keyboardSize.height;
scrollview.frame = viewFrame;

CGRect textFieldRect = [Field frame];
textFieldRect.origin.y += 10;
[scrollview scrollRectToVisible: textFieldRect animated:YES];
displayKeyboard = YES;
}

-(void) keyboardDidHide: (NSNotification *)notif {
if (!displayKeyboard) {
return;
}

scrollview.frame = 
CGRectMake(0, 0, SCROLLVIEW_CONTENT_WIDTH, SCROLLVIEW_CONTENT_HEIGHT);

scrollview.contentOffset =offset;

displayKeyboard = NO;

}

-(BOOL) textFieldShouldBeginEditing:(UITextField*)textField {
Field = textField;
return YES;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
Step 7: Now compile and run the application in the Simulator.




Download Updated SourceCode ScrollViewExample 2

Features of iPhone4


5 Megapixel Camera with LED Flash

Take beautiful, detailed photos with the new 5-megapixel camera with built-in LED flash. The advanced backside illumination sensor captures great pictures even in low light. And the new front-facing camera makes it easy to take self-portraits.

overview-camera-20100607.jpg


Facetime

People have been dreaming about video calling for decades. iPhone 4 makes it a reality. With just a tap, you can wave hello to your kids, share a smile from across the globe or watch your best friend laugh at your stories — iPhone 4 to iPhone 4 over Wi-Fi. No other phone makes staying in touch this much fun.

Two cameras,
two views.

iPhone 4 has two cameras: one on the front, which focuses on you. And one on the back, which focuses on everything else. FaceTime lets you switch back and forth between them at any time during a video call. All you have to do is tap a button.

Retina display

The Retina display on iPhone 4 is the sharpest, most vibrant, highest-resolution phone screen ever, with four times the pixel count of previous iPhone models. In fact, the pixel density is so high that the human eye is unable to distinguish individual pixels. Which makes text amazingly crisp and images stunningly sharp.
overview-retina-20100608.jpg

Multitasking

iPhone 4 introduces a whole new way of multitasking. Now you can run your favourite third-party apps — and switch between them instantly — without slowing down the performance of the foreground app or draining the battery unnecessarily.1 This smarter approach to multitasking is available only on iPhone.
overview-multitasking-20100607.jpg

HD Video Recording and Editing

Shoot your own movies in high definition. Capture impressive video even in low-light settings, thanks to the advanced backside illumination sensor and built-in LED light. Then edit and create your own mini-masterpiece right on iPhone 4 using the new iMovie app — with Apple-designed themes, titles and transitions. It’s coming soon to the App Store.
overview-hd-20100607.jpg

Folders for Apps

Organise apps into folders for fast access to your favourites.

iBooks

Available as a free download, iBooks is an amazing ebook reader and a great place to buy books.

Home Screen

Get one-tap access to everything on your iPhone and change the wallpaper to match your mood.

iMovie

Edit video, add themes and music, and share your movies. It’s coming soon to the App Store.

Phone

Built-in noise suppression makes phone calls easier to hear.

Mail

A unified inbox and other new features make Mail more powerful than ever.

Safari

The most advanced web browser on a mobile phone.

iPod

Play music and watch video in luminous colour.

Photos

View photos by Albums, Events, Faces and Places.

Voice Control

Make a call or play a song using just your voice.

Messages

Send messages with text, video, photos and more.

Maps + Compass

Find locations, get directions and orient yourself on the map.

Keyboard

The smart keyboard helps you type quickly and accurately.

Search

Find what you’re looking for across your iPhone or the web.

App Store

Discover hundreds of thousands of apps that let you do even more.

Accessibility

iPhone 4 comes with screen-reading technology and other accessibility features. for more details

http://www.apple.com/iphone/

Creating Digital Mockups For Your Apps




While conceptualizing your App, the first things you need to create is a flow chart of how your App will behave and some reference templates and images that will show you how each screen will look in your App. Here are some tools to help you do this.
While conceptualizing your App, the first things you need to create is a flow chart of how your App will behave and some reference templates and images that will show you how each screen will look in your App.

The first step to doing this is to get hold of a pencil and paper and make some rough sketches. Start by making a list of all the possible screens your app will have and then actually listing the functionality each screen will have. Once you have that, you can proceed to make some dummy mockup sketches. At this point you should focus on the “placement” elements of each screen… that is decide, what goes where. Next you can start to imagine the design elements and look and feel of each screen – and how they will all look similar and connect to one another. A flow chart showing how the connect up – will help. I suggest you get hold of a spiral bound sketch book and not lose sheets of paper, that can easily get misplaced. Any writing pad will also do.

To help you make your hard copy and soft copy drawings, these downloadable documents and plans will help you. They will be useful when you are brainstorming or trying to find the perfect flow for your app and putting the visual elements together.
  • Mock App – Templates for Keynote and Powerpoint
  • Yahoo Design Stencils – Yahoo! Design Stencil Kit version 1.0 is available for OmniGraffle, Visio (XML), Adobe Illustrator (PDF and SVG), and Adobe Photoshop (PNG)
Download each of the above packs and files as they are all must have tools when you or your graphic artist are planning the User Interface or graphic design of your Apps.

Playing Video file in Iphone


Let’s start by looking at a short video of the application. The basic idea to make this work is simple, your video content viewable in your simulator.
Step 1: Create a new project from Xcode using View-base application.
Step 2: We need to add some code in the header file.
#import <MediaPlayer/MediaPlayer.h>

#import <UIKit/UIKit.h>
@interface Tabbar1ViewController : UIViewController
{
MPMoviePlayerController *moviePlayer;
NSURL *movieURL;
}
Step 3: Now you add MediaPlayer.framework in your framework folder.Only shows up in the iPhone SDK frameworks folder, at  /Developer/platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/System/Library/Frameworks.


Step 4: In the controller file, we create the path to the movie, setup the movie player, register to receive a notification when the movie has finished playing, start the movie.

- (void) moviePlayBackDidFinish:(NSNotification*)notification 
{       
[[NSNotificationCenter defaultCenter] removeObserver:self
name:NULL
object:nil];
[movieURL release];
[moviePlayer release];
}

-(void)viewWillAppear:(BOOL)animated
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"video" 
    ofType:@"mov"];      
movieURL = [NSURL fileURLWithPath:path];

moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[moviePlayer setMovieControlMode:MPMovieControlModeHidden];  

[[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(moviePlayBackDidFinish:) 
name:MPMoviePlayerPlaybackDidFinishNotification 
object:nil];

[moviePlayer play];
}
 
Step 5: Now compile and run your application on the simulator

iPhone SDK Tip: Firing custom events when a link is clicked in a UIWebView

Well I have been asked this a few times and I can see how it would be a very helpful addition to theUIWebView’s feature set. What I am talking about is adding the ability to intercept the event generated when a user selects a link in a webpage being displayed with a UIWebView, this will then allow you to perform any action that you want.
When would you use this I hear you say? Well one person asked me if I knew how to append the users current location onto all HTTP requests? and another just wanted to know how to perform custom actions from an embedded UIWebView.

Once again I will be extending the “Build your very own Web Browser!”, if you haven’t already completed it then I suggest that you head over there now and spend 5 minutes reading it and then downloading the project files at the end.
Start by opening up the WebBrowserTutorialAppDelegate.h file and editing the @interface line to read:

@interface WebBrowserTutorialAppDelegate : NSObject  {
 
What we have done is to make the main AppDelegate a delegate for the UIWebView as well.
Now we need to set our webView to have the main AppDelegate as its delegate, you can do this by opening up WebBrowserTutorialAppDelegate.m and putting the following line just inside theapplicationDidFinishLaunching function:

webView.delegate = self;



That is all pretty self explanatory, it just sets the delegate of our webView to self, which in this case is our main application delegate.
Now we are pretty much done, we just need to add the function to catch the link clicks. To do this we need to add a new function, copy the content below to the WebBrowserTutorialAppDelegate.m file:

- (BOOL)webView:(UIWebView*)webView 
shouldStartLoadWithRequest:(NSURLRequest*)request 
navigationType:(UIWebViewNavigationType)navigationType {
NSURL *url = request.URL;
NSString *urlString = url.absoluteString;
NSLog(urlString);
return YES;
}
 
This function will catch all requests and allow you to either manipulate them and pass them on or to perform your own custom action and stop the event from bubbling.
The first line gets the URL of the request, this is the contents inside the href attribute in the anchor tag.
The next line converts the URL to a string so we can log it out. You can access many parts of the NSURL, here are some of them and brief description of what they do.

* absoluteString – An absolute string for the URL. Creating by resolving the receiver’s string against its base.
* absoluteURL – An absolute URL that refers to the same resource as the receiver. If the receiver is already absolute, returns self.
* baseURL – The base URL of the receiver. If the receiver is an absolute URL, returns nil.
* host – The host of the URL.
* parameterString – The parameter string of the URL.
* password – The password of the URL (i.e. http://user:pass@www.test.com would return pass)
* path – Returns the path of a URL.
* port – The port number of the URL.
* query – The query string of the URL.
* relativePath – The relative path of the URL without resolving against the base URL. If the receiver is an absolute URL, this method returns the same value as path.
* relativeString – string representation of the relative portion of the URL. If the receiver is an absolute URL this method returns the same value as absoluteString.
* scheme – The resource specifier of the URL (i.e. http, https, file, ftp, etc).
* user – The user portion of the URL.

Then the third line simply logs the URL to the console, so you will new to open up the console while you run this in the simulator to see the results.
Finally the forth line returns YES, this will allow the UIWebView to follow the link, if you would just like to catch a link and stop the UIWebView from following it then simply return NO.