iPhone XCode - Create a simple UIScrollView
Tech-Today

iPhone XCode - Create a simple UIScrollView


Finally getting acquainted with iPhone's xcode. Now I'll build a simple window base application to demo the UIScrollView features.

1.) Create a new window base application, named it MyScroll. It should create 2 files: a.) MyScrollAppDelegate.h and b.) MyScrollAppDelegate.m

2.) I'll explain the rest in code (Note I'm using UIImageView as the content of the UIScrollView):
#import <UIKit/UIKit.h>

@interface MyScrollAppDelegate : NSObject { //notice that we implement UIScrollViewDelegate, this is needed
UIWindow *window;
UIScrollView *scrollView; //declare a scrollview
UIImageView *imageView; //the object which we will add to scrollview
}

@property (nonatomic, retain) IBOutlet UIWindow *window;

@end

MyScrollAppDelegate.m
#import "MyScrollAppDelegate.h"

@implementation MyScrollAppDelegate

@synthesize window;

- (void)applicationDidFinishLaunching:(UIApplication *)application {
//initialize the scroll view
scrollView = [[UIScrollView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
scrollView.bouncesZoom = YES;
scrollView.backgroundColor = [UIColor orangeColor];
scrollView.delegate = self;

//create the image,
//note there should be an image in your Resources folder named edward.jpg
UIImage *image = [UIImage imageNamed:@"2.jpg"];
//we need to create a framework the ui image view
CGRect frame = CGRectMake(0, 0, image.size.width, image.size.height);
//initialize the ui image view
imageView = [[UIImageView alloc] initWithFrame:frame];
imageView.image = image;

//set the content size of the scroll view
//for more information please consult the UIScrollView's documentation
scrollView.contentSize = imageView.frame.size;

//set the zooming properties of the scroll view
scrollView.minimumZoomScale = scrollView.frame.size.width / image.size.width;
scrollView.maximumZoomScale = 2.0;

//add the image view to the scroll view
[scrollView addSubview:imageView];
[image release];

//add the scroll view to our main window
[window addSubview:scrollView];
// Override point for customization after application launch
[window makeKeyAndVisible];
}

//we zoom the image view
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return imageView;
}

- (void)dealloc {
[window release];
[super dealloc];
}

@end




- Swift Uiscrollview With Auto-layout And Size Classes
UIScrollView with Auto-Layout and Size ClassesA simple tutorial on making scrollable view that can accommodate any screen sizes. Download Link. 1.) First, of course we need a scrollview. So, drag a scrollview inside the storyboard and make sure that...

- Mobile Development
iPhone / XCode DevelopmentCreate an iphone application using xcode that dynamically creates sqlite tablesMy Todo List iphone application development using xcodeiPhone Development Making the Slider control workHow TosCreate an image slide show in iphone...

- How To Make A Static Splash Screen In Iphone Using Xcode
By default an xcode project created for iPhone looks for Default.jpg image in the resources. So all you need to do is: 1.) Make sure that you have a "Default.jpg" image in your Resources project folder 2.) In the class file that extends UIApplicationDelegate,...

- Create An Image Slide Show In Iphone Using Xcode
Here's how you can create image slide show from xcode - iphone Requirement:  -3 png images. 1.) Create a new View-based application project. Name it AnimationDemo. 2.) Once the new project is created. Add the 3 png images to the Resources folder....

- Iphone Xcode - How To Implement A Uitableview
In this demo I will extend the class UITableViewController, so I already have access to UITableViewDelegate and UITableViewDataSource classes. Steps: 1.) Create a new window based project. Named it MyTable. 2.) I will explain the rest in codes: MyTableAppDelegate.h...



Tech-Today








.