Loading

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;