extern or global variable
Create a new project,
Create extern variable in the header class
extern NSString *myexternalString;
in the implementation file define it at the top
NSString *myexternalString;
Now extern variable is ready you can set the value and use it in any other class you just have to import the header before using it in other classes.
here is the sample code
Saturday, November 26, 2011
Zooming UIImageView in iOS 5.0
Create a new project using xcode 4.0 with runtime iOS 5.0.
Suppose you have created view based project.
In root view controller class.
Add UIScrollView in xib and connect outlet to root ViewController.
Add UIImageView as subview on xib and connect its outlet to root ViewController OR create it writing code in root ViewController class and add subView to ScrollView.
Add UITapGestureRecognizer to UIImageView instance for single double taps and two finger touches.
set the UIScrollView's scale
// calculate minimum scale to perfectly fit image width, and begin at that scale
float minimumScale = [scrollView frame].size.width / [imageView frame].size.width;
scrollView.maximumZoomScale = 1.0;
scrollView.minimumZoomScale = minimumScale;
scrollView.zoomScale = minimumScale;
//note set the imageView's frame in ViewwillAppear or ViewDidAppear.
imageView.frame = CGRectMake(0,0, 320, 480);
when tap occurs at imageView, calculate the rect and set the rect to scroll view.
[scrollView zoomToRect:zoomRect animated:YES];
here is the sample code
Suppose you have created view based project.
In root view controller class.
Add UIScrollView in xib and connect outlet to root ViewController.
Add UIImageView as subview on xib and connect its outlet to root ViewController OR create it writing code in root ViewController class and add subView to ScrollView.
Add UITapGestureRecognizer to UIImageView instance for single double taps and two finger touches.
set the UIScrollView's scale
// calculate minimum scale to perfectly fit image width, and begin at that scale
float minimumScale = [scrollView frame].size.width / [imageView frame].size.width;
scrollView.maximumZoomScale = 1.0;
scrollView.minimumZoomScale = minimumScale;
scrollView.zoomScale = minimumScale;
//note set the imageView's frame in ViewwillAppear or ViewDidAppear.
imageView.frame = CGRectMake(0,0, 320, 480);
when tap occurs at imageView, calculate the rect and set the rect to scroll view.
[scrollView zoomToRect:zoomRect animated:YES];
here is the sample code
Thursday, October 13, 2011
Automatic Reference Counting
ARC seems to be a great feature.
I found some useful links to know more about that
ARC Apple Docs
ARC
I found some useful links to know more about that
ARC Apple Docs
ARC
How to Add Frame work in Xcode 4 and ios 5.0
1. Select the project on top at left side.
2. Select Targets
3. under Link Binary with Libraries, click on + that will open a list and select the frame work from that list.
2. Select Targets
3. under Link Binary with Libraries, click on + that will open a list and select the frame work from that list.
Subscribe to:
Posts (Atom)