Loading

Wednesday, December 29, 2010

Store imge from URL to app bundle

NSString *StrUrl=[[NSString alloc] initWithFormat:@"%@",yourURLstring];
NSData *_PicData=[[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:StrUrl] ];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath =[NSString stringWithFormat:@"%@/%@",[paths objectAtIndex:0],YourPhotoName.Ext];
[_PicData writeToFile:documentsPath atomically:YES];

Tuesday, October 19, 2010

Table Scroll to Top

if([result count]>0)
{
NSIndexPath* indPath = [NSIndexPath indexPathForRow:0 inSection:0];
[tblArticle scrollToRowAtIndexPath:indPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
}

Use of Autorelase Pool

The First line of Thread =

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];


and the Last Line is

[pool release];

Tuesday, October 12, 2010

Hide ActivityIndicator When Page DidFinish Loading

1. [WebViewWebDetail loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@""]]];

NSString* WebAddress=[NSString stringWithFormat:@"%@",YourWebAddress];
NSURL* url=[NSURL URLWithString:[WebAddress stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[WebViewWebDetail loadRequest:[NSURLRequest requestWithURL:url]];


2. WEBVIEW Delegate Methods

- (void)webViewDidStartLoad:(UIWebView *)webView
{
Process.alpha=1.0;
Process.hidesWhenStopped = YES;
[Process startAnimating];

}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
if([Process isAnimating])
[Process stopAnimating];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{

if([Process isAnimating])
[Process stopAnimating];
/*
if (error != NULL) {
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle: [error localizedDescription]
message: [error localizedFailureReason]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[errorAlert show];
[errorAlert release];
}*/
}

Wednesday, September 29, 2010

Color With Image Pattern

NSString *backgroundPath = [[NSBundle mainBundle] pathForResource:@"Display" ofType:@"png"];
UIImage *backgroundImage = [UIImage imageWithContentsOfFile:backgroundPath];

return [UIColor colorWithPatternImage:backgroundImage];

Remove Horizental Scrollindicator from Code

scrl.scrollIndicatorInsets=UIEdgeInsetsMake(0, 0, 0, -10);

Monday, September 20, 2010

X,Y and Z Position of Device

1. include UIAccelerometerDelegate in .h file

2. Declare UIAccelerationValue acceleration[3]; in .h

3. [[UIAccelerometer sharedAccelerometer] setDelegate:self]; in ViewDidLoad or ViewWillAppear

4. - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
[self updateHistoryWithX:acceleration.x Y:acceleration.y Z:acceleration.z];
} // Delegate method

- (void)updateHistoryWithX:(float)x Y:(float)y Z:(float)z {

NSLog(@"X=%f Y=%f Z=%f ",x,y,z);
}

Auto Orientation

Go Through

http://developer.apple.com/library/ios/#codinghowtos/UserExperience/index.html

Saturday, September 18, 2010

Push 2 View Controller from App Stack

YourAppDelegate* appDelegate = (YourAppDelegate*)[UIApplication sharedApplication].delegate;
UINavigationController *navigationController = [appDelegate navigationController];
NSInteger Go_To_Controller=[navigationController.viewControllers count]-3;
[navigationController popToViewController:[navigationController.viewControllers objectAtIndex:Go_To_Controller] animated:YES];

Friday, September 17, 2010

Resize The Image for Save

NSData *imgdata = UIImageJPEGRepresentation([PhotoArray objectAtIndex:0], 0.85f);
UIImage *image = [UIImage imageWithData:imgdata];
CGRect rect = CGRectMake(0.0, 0.0, 320, 480);
UIGraphicsBeginImageContext(rect.size);
[image drawInRect:rect];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *imgdata1 = UIImageJPEGRepresentation(img, 0.6);

Hide Callout

NSArray *arr=YourmapView.selectedAnnotations;
MKAnnotation *Curranno=[arr objectAtIndex:0];
[YourmapView deselectAnnotation:Curranno animated:YES];

Thursday, August 26, 2010

Cell For Particular Index

\\Set YourButton.Tag When Create Custom Cell [YourButton SetTag:IndexPath.Row];

-(IBAction)YourButton_TouchUpInside:(id)sender
{
CustomTVCellComments *cell=[tblComment cellForRowAtIndexPath:[NSIndexPath indexPathForRow:[sender tag] inSection:0]];
cell.YouribOutletHere=Some Code;
}

Wednesday, August 25, 2010

Fade Effect For View

YourView.Alpha=0.0
[UIView beginAnimations:nil context:NULL];
// [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:YourView cache:YES];
[UIView setAnimationDuration:1.5];
[YourView setAlpha:1.0];
[UIView commitAnimations];

Tuesday, August 24, 2010

Compas Working

1. --> in .h File include -->CLLocationManagerDelegate

2. in .m FIle --- >
a. ViewDidLoad LManager=[[CLLocationManager alloc]init];
LManager.desiredAccuracy = kCLLocationAccuracyBest;
LManager.delegate=self;
[LManager startUpdatingHeading];
Degree=0;


b. Delegate Methods - (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
Compass_Not_Dect_Camera.hidden=YES;
double curLocation=newHeading.magneticHeading;
if(PreLocation-curLocation>5 || PreLocation-curLocation<-5)
{
CGAffineTransform rotate = CGAffineTransformMakeRotation( newHeading.magneticHeading/180*3.14 );
[arrow setTransform:rotate];
Degree=newHeading.magneticHeading;
Degree=Degree/90;
PreLocation=newHeading.magneticHeading;
}
}

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{

[LManager stopUpdatingLocation];
[LManager release];
Compass_Not_Dect_lbl.text=@"Compass Not Detected";

}

Image Of An Image View through Url

NSURL* _picUrl=[NSURL URLWithString:@"ImageUrl"];
NSData* _picData=[[NSData alloc] initWithContentsOfURL:_picUrl];
imgDetails.image=[UIImage imageWithData:_picData];

Detect Shake in iPhone

1. in .h File --->#define kAccelerationThreshold 2.2

2. include UIAccelerometerDelegate

3. in .m File --> ViewDidload -->[[UIAccelerometer sharedAccelerometer] setDelegate:self];

4. #pragma mark -
#pragma mark Shake event

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
if (fabsf(acceleration.x) > GlobalRate || fabsf(acceleration.y) > GlobalRate || fabsf(acceleration.z) > GlobalRate)
{
// Your Code Here
}
}

Wednesday, August 4, 2010

Tuesday, July 20, 2010

What is Annotation ???

It is a pre-Declared Class.
You have to define it in your project.
The Annotation class must have three property
1-> coordinate
2-> title
3-> subtitle

:)
also declare and define method for initiate Annotation (it is user Define)

Example :-
Add New Class in Project Named MyAnnotaion
MyAnnotation.h

@interface MyAnnotation : NSObject {
CLLocationCoordinate2D _coordinate;
NSString* title;
NSString* subtitle;
}

@property (nonatomic, retain)NSString* title;
@property (nonatomic, retain)NSString* subtitle;

- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate: (NSString*)annTitle : (NSString*)annSubTitle;
@end

MyAnnotation.m

@synthesize coordinate=_coordinate;
@synthesize title;
@synthesize subtitle;


- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate: (NSString*)annTitle : (NSString*)annSubTitle{
self = [super init];
if (self != nil) {
_coordinate = coordinate;
title = annTitle;
subtitle = annSubTitle;
}
return self;
}



Thursday, July 15, 2010

Smooth Line Eraser From View

UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView:touch.view];
touchLocation = [touch locationInView:self.view];
CGPoint currentPoint = [touch locationInView:self.view];
CGContextRef Mycontext=UIGraphicsGetCurrentContext();

UIGraphicsBeginImageContext(Image_Cookie.frame.size);
[Image_Cookie.image drawInRect:CGRectMake(0, 0, Image_Cookie.frame.size.width, Image_Cookie.frame.size.height)];
CGContextSetLineCap(Mycontext,kCGImageAlphaPremultipliedLast); //kCGImageAlphaPremultipliedLast);
CGContextSetLineWidth(Mycontext, 10);
CGContextSetRGBStrokeColor(Mycontext, 1, 0, 0, 20);
CGContextBeginPath(Mycontext);
CGContextMoveToPoint(Mycontext, lastPoint.x, lastPoint.y);

int x, cx, deltax, xstep,y, cy, deltay, ystep,error, st, dupe;
int x0, y0, x1, y1;

x0 = currentPoint.x;
y0 = currentPoint.y;
x1 = lastPoint.x;
y1 = lastPoint.y;

// find largest delta for pixel steps
st = (abs(y1 - y0) > abs(x1 - x0));

// if deltay > deltax then swap x,y
if (st) {
(x0 ^= y0); (y0 ^= x0); (x0 ^= y0); // swap(x0, y0);
(x1 ^= y1); (y1 ^= x1); (x1 ^= y1); // swap(x1, y1);
}

deltax = abs(x1 - x0);
deltay = abs(y1 - y0);
error = (deltax / 2);
y = y0;

if (x0 > x1) { xstep = -1; }
else { xstep = 1; }

if (y0 > y1) { ystep = -1; }
else { ystep = 1; }

for ((x = x0); (x != (x1 + xstep)); (x += xstep))
{
(cx = x); (cy = y); // copy of x, copy of y

// if x,y swapped above, swap them back now
if (st) { (cx ^= cy); (cy ^= cx); (cx ^= cy); }

(dupe = 0); // initialize no dupe

if(!dupe) {
CGContextClearRect(UIGraphicsGetCurrentContext(), CGRectMake(cx, cy,40, 40));
}

(error -= deltay); // converge toward end of line

if (error < 0) { // not done yet
(y += ystep);
(error += deltax);
}
}

CGContextStrokePath(Mycontext);
Image_Cookie.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

lastPoint = currentPoint;

Friday, July 9, 2010

Compass Niddel Set By User

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
theEndPoint = [touch locationInView:self.view];
if((theEndPoint.x>My_Compass.frame.origin.x && theEndPoint.y>My_Compass.frame.origin.y) && (theEndPoint.x {
float Centre_X = My_Compass.frame.origin.x + (My_Compass.frame.size.height/2);
float Centre_Y = My_Compass.frame.origin.y + (My_Compass.frame.size.width/2);

float dx=theEndPoint.x-Centre_X;
float dy=theEndPoint.y-Centre_Y;

double angle=atan2(dy,dx);
double br = RadiansTodegrees(angle);

CGAffineTransform rotate = CGAffineTransformMakeRotation(((br+90)/180)*3.14);
[Niddel setTransform:rotate];

}

}

Monday, July 5, 2010

Rename Project

Just Change the value of Bundle Display Name to My Project from ${PRODUCT_NAME}

Wednesday, June 30, 2010

Erase The Image

- (void)viewDidLoad
{
[super viewDidLoad];
drawImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Picture 1.png"]];
frontImage = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 240.0f, 240.0f)];
frontImage.image = [UIImage imageNamed:@"P1Mother0091.1.png"];
frontImage.opaque = NO;
[self.view addSubview:drawImage];
[drawImage addSubview:frontImage];
self.view.backgroundColor = [UIColor lightGrayColor];
mouseMoved = 0;
mouseSwiped = YES;
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {


UITouch *touch = [touches anyObject];

if ([touch tapCount] == 2) {

return;
}

lastPoint = [touch locationInView:frontImage];
lastPoint.y -= 20;

}


- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{


UITouch *touch = [touches anyObject];
CGPoint currentPoint = [touch locationInView:frontImage];
currentPoint.y -= 20;

//erase part
if(mouseSwiped)
{

//**************Working Code*************//


UIGraphicsBeginImageContext(frontImage.frame.size);
[frontImage.image drawInRect:CGRectMake(0, 0, frontImage.frame.size.width, frontImage.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGImageAlphaNone); //kCGImageAlphaPremultipliedLast);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 10);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1, 0, 0, 10);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextClearRect (UIGraphicsGetCurrentContext(), CGRectMake(lastPoint.x, lastPoint.y, 10, 10));
CGContextStrokePath(UIGraphicsGetCurrentContext());
frontImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();


lastPoint = currentPoint;

mouseMoved++;

if (mouseMoved == 10)
{
mouseMoved = 0;
}
}

//Unerase part
if(!mouseSwiped)

{

//UIGraphicsBeginImageContext(self.view.frame.size);
UIGraphicsBeginImageContext(frontImage.frame.size);
[frontImage.image drawInRect:CGRectMake(0, 0, frontImage.frame.size.width, frontImage.frame.size.height)];
//brushContext = CGBitmapContextCreate(brushData, width, width, 8, width * 4, CGImageGetColorSpace(brushImage), kCGImageAlphaPremultipliedLast);
CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGImageAlphaNone); //kCGImageAlphaPremultipliedLast);
//kCGImageAlphaPremultipliedLast
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 10);
//CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 1.0, 0.0, 1.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1, 0, 0, 10);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
//CGContextRestoreGState(UIGraphicsGetCurrentContext());
CGContextRetain(UIGraphicsGetCurrentContext());
//CGContextStrokePath(UIGraphicsGetCurrentContext());
frontImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

}
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

UITouch *touch = [touches anyObject];

if ([touch tapCount] == 2) {
//drawImage.image = nil;
return;
}

// Unerase part
if(!mouseSwiped)

{

//UIGraphicsBeginImageContext(self.view.frame.size);
UIGraphicsBeginImageContext(frontImage.frame.size);
[frontImage.image drawInRect:CGRectMake(0, 0, frontImage.frame.size.width, frontImage.frame.size.height)];
//brushContext = CGBitmapContextCreate(brushData, width, width, 8, width * 4, CGImageGetColorSpace(brushImage), kCGImageAlphaPremultipliedLast);
CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGImageAlphaNone); //kCGImageAlphaPremultipliedLast);
//kCGImageAlphaPremultipliedLast
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 10);
//CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 1.0, 0.0, 1.0);
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1, 0, 0, 10);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
//CGContextStrokePath(UIGraphicsGetCurrentContext());
frontImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

}
}

Sunday, June 27, 2010

Map View Delegate Methods

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation
{
MKAnnotationView *tmp=[[MKAnnotationView alloc]initWithFrame:CGRectMake(10,10,30,30)];
tmp.image=[UIImage imageNamed:[NSString stringWithFormat:@"Pin.png"]];
[tmp addObserver:self forKeyPath:@"selected" options:NSKeyValueObservingOptionNew context:@"selectedmapannotation"];
return tmp;

}


- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
NSString *action = (NSString*)context;

if([action isEqualToString:@"selectedmapannotation"]){
BOOL annotationAppeared = [[change valueForKey:@"new"] boolValue];
// MKAnnotationView *ann = (MKAnnotationView *)object;

if (annotationAppeared)
{
NSLog(@"Wow it's Selected :-) ");
}
else
{
NSLog(@"Opps it's Not Selected :-( ");
}
}
}

Thursday, June 17, 2010

Info Button Function

1--> Create a info button on XIB and Bind it with function
2--> Declare a BOOL Variable init with YES;
NOTE :- There is Three View in XIB
1-> self.View
2->RootView
3->Info_View


[UIView beginAnimations:nil context:nil];
if(Flip_Flag)
{
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
}
else
{
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
}
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(test)];
[UIView setAnimationDuration:.5];
if(Flip_Flag)
{
[Info_View removeFromSuperview];
[self.view addSubview:RootView];
Flip_Flag=NO;
}
else
{
[RootView removeFromSuperview];
[self.view addSubview:Info_View];
Flip_Flag=YES;
}
[UIView commitAnimations];

Tuesday, June 15, 2010

Touch in Particular Area of Screen

-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{

UITouch *touch = [[event allTouches] anyObject];
// get the touch location
CGPoint touchLocation = [touch locationInView:touch.view];
if(touchLocation.x>40 && touchLocation.x<263>68 && touchLocation.y<340 )
{
TRUE PART;
}
else
{
FALSE PART
}

Customize Back Button of Navigation Controller

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(btnSearchBackAction:) forControlEvents:UIControlEventTouchUpInside];
[button setFrame:CGRectMake(0, 0, 32, 32)];

iPhone & iPad apps with special url shortcuts

A feature of the iPhone SDK allows you to bind your application to a custom url scheme. This allows others to trigger the opening of your app and opens the possibilities of passing data between apps.

Here’s a quick tutorial on how to update your Info.plist to register your own url.

List of iPhone apps with custom url shortcuts along with instructions on how to use them.

Safari

Phone Call

SMS / Text Message

  • sms:123456789There is no // in the SMS scheme.
  • Note: Currently no method to specify a body for the message.

Send an Email

AppStore

Like YouTube and Google Maps, certain http urls get hijacked by the build in Apple apps. This will open the Appstore app.

  • http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=291586600&mt=8

Maps

  • Launch the mapping app – maps://

Feed Reader

  • feed:// launches http://reader.mac.com in Safari

Twitteriffic / Twitteriffic Premium

A Twitter client by The Icon Factory

Twinkle

Twitter client by Tapulous
  • Launch – twinkle://

Tweetie

Twitter client by atebits
  • Launch – tweetie://
  • Start tweet with shortened url – tweetie://http://your.url.com

Twitterfon

Twitter client by

Site Check

Phishing Protection for Mobile Safari by Kevin O’Reganapps_ie_textonly_on_white

Credit Card Terminal

Online CC processing by InnerFence

This is one of the first iphone apps to provide a return path when it is invoked. See this post on their blog for more details and some security caveats.

Yummy

by Stephen Darlington

Appigo Todo

Todo list management by Appigo

Appigo Notebook

Notepad by Appigo

Darkslide (formerly Exposure)

Flickr viewer by Connected Flow
Portscanner by Digital Sirup
  • Launch Portscanner – portscan://
  • Launch a scan – portscan://127.0.0.1
  • Launch a scan – portscan://host.name

ChatCo

English/Japanese IRC client

  • irc://irc.example.domain/roomName
  • irc://irc.example.domain/Nickname@roomName
  • irc://irc.example.domain/Nickname!Realname@roomName

Eureka

Wikipedia Viewer by Keishi Hattori

Wikiamo

Wikipedia viewer by Satoshi Nakagawa
First one seen with 2 url schemes registered

Ships² Viewer

Game by Universalis

Geopher Lite

Geocaching app by DadGuy

Google Earth

by Google

Alocola

by Dan Grigsby / Mobile Orchard

An iPhone location web-helper application

Kindle

by Amazon

Amazon Kindle book reader

UniDict Engine & SpellChecker

by Enfour

Enfour has a number of apps that support round-trip URLs -add the sender app’s URL to the ‘Back’ button.

“UniDict Engine” (used for dictionaries like “American Heritage” & “Oxford Deluxe“) allows lookups from other applications as well as links between dictionaries.

SpellChecker” also has round trip URLs. This lets apps send text to be checked with the results sent back to the app that made the call.


Skype

by Skype

VOIP Calls and Chat


Ebay

by Ebay

Auctions


Facebook

by Facebook

Social Networking


EirText Pro

by Vincent Coyne – apps_ie_textonly_on_white

SMS Client


iVersion

by Ben Reeves

Fully featured SVN Client for iPhone and iPod Touch


Round Tuit

by Leigh McCulloch

Use Round Tuit to keep a quick and easy list of things you need to get done. Add new items, delete items and order your items according to what you need to do next and make a productive difference to your day.


Gowalla

by Alamofire, Inc

Share your experiences through Gowalla with your Facebook & Twitter friends


Print Magic

by Wellala Inc

“Print Magic is the first application for the Apple iPhone & iTouch products, which allows for wireless printing through IPP on the latest OS system”

  • Launch with print:// Data in the pasteboard will be printed.


Birdfeed

by BirdFeed

Twitter Client


MyAppSales

by Dr. Touch

Download your iTunes Connect reports. (Not available from the AppStore, sold as source fo you to build and run via your developer account)


Sounds real (sound bank)

by Série Blanche

Sounds real (sound bank)


Simply Tweet

by Hwee Boon Yar

Twitter client with push notifications


Echofon

by Naan Studio

Twitter client


Good Reader

by Good.iWare Ltd

Download files for use offline

  • Launch from another app gropen:// (help)
  • Download files ghttp://, ghttps://, grhttp://, grhttps://, giwhttp:// or giwhttps:// (help)


Pocket Universe

by John Kennedy

Pocket Universe supports the following options (more to come), which makes it possible to link to planets or points in the sky from a web page and then ’see’ them in the app’s planetarium mode. Motion tracking mode must be off for these to function as expected.

Monday, June 14, 2010

Open Safari With URL

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]];

Uses Of NSUserDefaults

THIS CODE WILL RUN THE APPLICATION 6 TIMES AND THEN SHOW THE MESSAGE


//[[NSUserDefaults standardUserDefaults] setObject:@"True" forKey:@"checkSelect"];
//if([[[NSUserDefaults standardUserDefaults] objectForKey:@"checkSelect"] isEqualToString:@"True"])
if([[NSUserDefaults standardUserDefaults]integerForKey:@"App_Testy_ICream_Counter"]==0)
{
[[NSUserDefaults standardUserDefaults]setInteger:1 forKey:@"App_Testy_ICream_Counter"];
}
else if([[NSUserDefaults standardUserDefaults]integerForKey:@"App_Testy_ICream_Counter"]<6)
{
int i=[[NSUserDefaults standardUserDefaults]integerForKey:@"App_Testy_ICream_Counter"];
i++;
[[NSUserDefaults standardUserDefaults]setInteger:i forKey:@"App_Testy_ICream_Counter"];
}
else
{
UIAlertView * alert=[[UIAlertView alloc] initWithTitle:@"Sorry" message:@"We're glad you've enjoyed playing with Tasty Ice Cream! Please take the time to rate this app" delegate:self cancelButtonTitle:@"Not right now" otherButtonTitles:@"Sure",nil];
[alert show];


[[NSUserDefaults standardUserDefaults]setInteger:1 forKey:@"App_Testy_ICream_Counter"];

}

Find The Index of Selected Row Of Picker View

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
lbl.text = [arr_tmp objectAtIndex:[pickerView selectedRowInComponent:0]];
if([arr_tmp indexOfObject:[arr_tmp objectAtIndex:[pickerView selectedRowInComponent:0]]]==0)
{
// Statement of Condation if Index At 0
}
else if([arr_tmp indexOfObject:[arr_tmp objectAtIndex:[pickerView selectedRowInComponent:0]]]==1)
{
// Statement of Condation if Index At 1
}
else if([arr_tmp indexOfObject:[arr_tmp objectAtIndex:[pickerView selectedRowInComponent:0]]]==2)
{

// Statement of Condation if Index At 2
}
}

NOTE :- arr_tmp is the Array which's elements disply's in Picker View

Create Screen Shot of application

-(void) Save_Img
{
UIImageView *Img_Screen=[[UIImageView alloc]init];
UIGraphicsBeginImageContext(self.view.bounds.size); //self.view.window.frame.size
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
Img_Screen.image =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(Img_Screen.image, nil, nil, nil);
[Img_Screen release];
}

NOTE :- Remember to add #import QuartzCore/QuartzCore in .m

Sunday, June 13, 2010

Play Sound Effect

1---> Import AVFoundation.framework
2---> -(void) PlayMusicSound: (NSString *)SoundFileName ForNumberOfLoops:(NSInteger)numLoops Extension:(NSString *)SoundExtension; // in .h file
3---> #import // in .m file
4---> -(void) PlayMusicSound: (NSString *)SoundFileName ForNumberOfLoops:(NSInteger)numLoops Extension:(NSString *)SoundExtension
{
//[player stop];
//self.SoundPlaying = SoundFileName;
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: SoundFileName ofType: SoundExtension];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];

AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL: fileURL error: nil];
player.numberOfLoops = numLoops;
[fileURL release];

[player play];
[player setDelegate: self];
}

5---> call [self PlayMusicSound:@"Bite" ForNumberOfLoops:0 Extension:@"wav"];

PageControl Without Application Delegates

1---> Create A Scroll View With Array Of Views
Each View's Dimension is 320x420
2---> in viewDidLoad ->
Arr_Element=[[NSMutableArray alloc]initWithObjects:@"First",@"Second",@"Third",@"Fourth",nil];
Arr_Count=[Arr_Element count]; //Arr_Count-> int
[Scrl setContentSize:CGSizeMake(Arr_Count*320,Scrl.bounds.size.height)];
pageControl.numberOfPages = Arr_Count;
pageControl.currentPage = 0;
for(int i=0;i {

UIView *Page_View=[[UIView alloc]initWithFrame:CGRectMake(i*320, 0, 320,420)];
UILabel *Lbl=[[UILabel alloc]initWithFrame:CGRectMake(10,10,300, 50)];
Lbl.text=[NSString stringWithFormat:@"%@",[Arr_Element objectAtIndex:i]];
Page_View.backgroundColor=[UIColor blueColor];
[Page_View addSubview:Lbl];
[Scrl addSubview:Page_View];
[Page_View release];
[Lbl release];
}

3---> - (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat pageWidth = Scrl.frame.size.width;
int page = floor((Scrl.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
pageControl.currentPage = page;
pageControl.frame=CGRectMake(Scrl.contentOffset.x,415,320, 36);
}

4---> - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
pageControl.currentPage = (int)Scrl.contentOffset.x/320;
pageControl.frame=CGRectMake((int)Scrl.contentOffset.x,415,320, 36);
}

5---> -(void)Change:(id)sender
{
[Scrl scrollRectToVisible:CGRectMake(320*pageControl.currentPage, 0,320, 420) animated:YES];
}
6---> And Refer Change Method With PageControl-> Value Change

Saturday, June 12, 2010

eMail Functions

1 -> -(void) prepareHmlDataAndSendEmail
{

CGRect tmp=CGRectMake(0 ,80,320,480);
[Scroll_View_Img_Cone scrollRectToVisible:tmp animated:NO];

Seg_Ctrl.hidden=YES;
Flag_Srl=Scroll_View.hidden;
Flag_Srl_Cone=Scroll_View_Cone.hidden;
Flag_Srl_ICream=Scroll_View_ICream.hidden;
Flag_Srl_Topping=Scroll_View_Topping.hidden;

Scroll_View.hidden=YES;
Scroll_View_Cone.hidden=YES;
Scroll_View_ICream.hidden=YES;
Scroll_View_Topping.hidden=YES;


UIImageView *Img_Screen=[[UIImageView alloc]init];
UIGraphicsBeginImageContext(self.view.bounds.size); //self.view.window.frame.size
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
Img_Screen.image =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();



MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;

NSString * HTMLData = @"Hi,

";
picker.navigationController.navigationBar.barStyle = UIBarStyleBlack;
[picker setSubject:@"Tasty Ice-Cream"];
NSArray *toRecipients = [NSArray arrayWithObject:@""];
[picker setToRecipients:toRecipients];
[picker setMessageBody:HTMLData isHTML:YES];
if(Img_Screen.image != nil){
[picker addAttachmentData: UIImagePNGRepresentation(Img_Screen.image) mimeType: @"image/png" fileName:@"Ice-Cream.png"];
}
// Add Some String TO Bottom :)
Img_Screen.frame=CGRectMake(0,0,320,100);
Img_Screen.image=[UIImage imageNamed:[NSString stringWithFormat:@"Bottom Picture.png"]];
if(Img_Screen.image != nil)
{
[picker addAttachmentData: UIImagePNGRepresentation(Img_Screen.image) mimeType: @"image/png" fileName:@"Ice-Cream.png"];
}

[self presentModalViewController:picker animated:YES];
[picker release];

[Img_Screen release];

Scroll_View.hidden=Flag_Srl;
Scroll_View_Cone.hidden=Flag_Srl_Cone;
Scroll_View_ICream.hidden=Flag_Srl_ICream;
Scroll_View_Topping.hidden=Flag_Srl_Topping;
Seg_Ctrl.hidden=NO;


tmp=CGRectMake(0,0,320,480);
[Scroll_View_Img_Cone scrollRectToVisible:tmp animated:NO];
}



2--> Customize Message
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{

switch (result)
{
//UIAlertView * alert = [UIAlertView alloc];
case MFMailComposeResultCancelled:
{
UIAlertView * alert=[[UIAlertView alloc] initWithTitle:@"Tasty Ice-Cream" message:@"Mail Cancelled" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[self Restart];
return;
break;
}
case MFMailComposeResultSaved:
{
UIAlertView * alert=[[UIAlertView alloc] initWithTitle:@"Tasty Ice-Cream" message:@"Mail Saved" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[self Restart];
return;
break;
}
case MFMailComposeResultSent:
{
UIAlertView * alert=[[UIAlertView alloc] initWithTitle:@"Tasty Ice-Cream" message:@"Mail Sent" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[self Restart];
return;
break;
}
case MFMailComposeResultFailed:
{
UIAlertView * alert=[[UIAlertView alloc] initWithTitle:@"Tasty Ice-Cream" message:@"Mail Failed" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[self Restart];
return;
break;
}
default:
{
UIAlertView * alert=[[UIAlertView alloc] initWithTitle:@"Tasty Ice-Cream" message:@"Mail Not Sent" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
[self Restart];
return;
break;
}
}

[self dismissModalViewControllerAnimated:YES];
[self.navigationController popViewControllerAnimated:YES];
}

3--> Remember to Add MessageUI.FrameWork

To Hide The Navigation Bar

self.navigationController.navigationBarHidden=YES;