Implement Scrolling In iPhone

In this application we will see how to implement two different style UIScrollViews. The first scroller contains multiple images, showing how to layout large content with multiple chunks of data.

Step 1: Create a Window base application using template. Give the application name Scroll Image.

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: Now we’ll add view controller class to the project. Choose New file -> Select cocoa touch classes group and then select UIViewController subclass. Give the name Scroll ImageViewController.

Step 4: In the AppDelegate.h file, we add the Scroll_ImageViewController, make the following changes in the header file.

 

 

 

Step 5: In the AppDelegate.m file make the following changes:

 

 

 

Step 6: We are added UIScrollView in the Scroll ImageViewController.h file. Make the following changes.

 

 

 

Step 7: Now double click the MainWindow.xib file and open it to the Interface Builder. Drag ViewController from the library and place it to the main window. Select the viewcontroller icon and bring up Identity Inspector  change the class name  into the Scroll ImageViewController. Open the view window , drag view from the library and place it to the view window. Drag scroll image from the library and place it on the view window (See the figure below). Connect Scroll_ImageAppDelegate to the Scroll_ImageViewController . We are added two UIScrollView in the View window. Select one UIScrollView and bring up connection Inspector connect scrollView1 to the Scroll_ImageViewController. Do it once more time for scrollView2. Now save the .xib file and go back to the Xcode.

Step 8: Make the following changes in the Scroll ImageViewController.m file.

 

 

 

Step 9: Compile and run the application in the simulator.

You can downloaded SourceCode from here Scroll Image 2

Leave a Comment:

1 comment
santhosh says January 12, 2011

The tutorial is very good..

Reply
Add Your Reply