- (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();
}
}
Wednesday, June 30, 2010
Erase The Image
Sunday, June 27, 2010
Map View Delegate Methods
{
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 :-( ");
}
}
}
Wednesday, June 23, 2010
Thursday, June 17, 2010
Info Button 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
{
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
[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
- http://
- https://
- ftp:// e.g. ftp://ftp.mozilla.org/pub/
Phone Call
SMS / Text Message
- sms:123456789 – There 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
- Launch –
twitterrific://
- Start a tweet –
twitterrific:///post?message="message body"
Twinkle
- Launch – twinkle://
Tweetie
- Launch – tweetie://
- Start tweet with shortened url – tweetie://http://your.url.com
Twitterfon
- Start tweet of url – twitterfon:///post?’+window.location
Site Check
Phishing Protection for Mobile Safari by Kevin O’Regan –
- Launch –
checkit://
- Check current url by prefixing with
checkit://
e.g.checkit://http://quinagh.com
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.
- Launch – com-innerfence-ccterminal://
- See integration documentation for return url and other parameters (Developer integration docs)
Yummy
Appigo Todo
Todo list management by Appigo
- Launch – appigotodo://
- Create a new todo – appigotodo://com.example.xyzapp/import?name=Buy%20some%20milk¬e=Stop%20on%20the%20way%20home%20from%20work.&due-date=2009-07-16&priority=1&repeat=101
- See full document on linking to Todo.
Appigo Notebook
Notepad by Appigo
- Launch appigonotebook://
- More…
- Review (148Apps.com)
- 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
- Substitute eureka for http e.g. eureka://en.wikipedia.org/wiki/Apple
Wikiamo
Wikipedia viewer by Satoshi Nakagawa
First one seen with 2 url schemes registered
- Substitute http for wikipedia or wikiamo
- wikipedia:// or wikiamo://
Ships² Viewer
Game by Universalis
- Launch with ships2://
Geopher Lite
- geopherlite://setTarget;lat=12.345;lon=6.789;waypoint=GC12345
- Waypoint info from geocaching.com
- Blog post on this feature
Google Earth
by Google
- Launch with comgoogleearth://
Alocola
by Dan Grigsby / Mobile Orchard
An iPhone location web-helper application
- Launch with alocola://
- More…
Kindle
by Amazon
Amazon Kindle book reader
- Launch with kindle:/home
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.
- Contact Enfour for details.
Skype
by Skype
VOIP Calls and Chat
- Launch with skype:
- Make a call skype:echo123?call – ‘echo123′ is the skype test number.
- Make a call skype:+353991234567?call – Full tel number including country code.
- more…
Ebay
by Ebay
Auctions
- Launch with ebay:
by Facebook
Social Networking
- Launch with fb//:
EirText Pro
SMS Client
- Launch with eirtext//:
iVersion
by Ben Reeves
Fully featured SVN Client for iPhone and iPod Touch
- Launch with svn://
- Open a session svn://user:pass@host.com/path/trunk
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.
- Launch with roundtuit://
- Add Todo items roundtuit://add/[todo item 1]/[todo item 2]/[todo item 3]/
Gowalla
by Alamofire, Inc
Share your experiences through Gowalla with your Facebook & Twitter friends
- Launch with gowalla://
- Open spot 123 gowalla://spots/123
- Open user 123 gowalla://users/123
- Open trip 123 gowalla://users/123
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
- Launch with x-birdfeed://
- More options available
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)
- Launch with myappsales://
- Go to reports myappsales://reports
- Go to specific report myappsales://reports/report_date=2010-01-01®ion=0&type=0
Sounds real (sound bank)
by Série Blanche
Sounds real (sound bank)
- Launch with soundsreal://
Simply Tweet
by Hwee Boon Yar
Twitter client with push notifications
- Launch with simplytweet:
- Friends simplytweet:?timeline=friends
- Mentions simplytweet:?timeline=mentions
- Direct messages simplytweet:?timeline=directmessages
- Starts a new draft simplytweet:?link={URL}&text={text}
Echofon
by Naan Studio
Twitter client
- Launch with echofon:///post?’+window.location (Echofon)
- Launch with echofonpro:///post/username?’+window.loaction (Echofon Pro)
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
Uses Of NSUserDefaults
//[[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
{
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
{
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
Sunday, June 13, 2010
Play Sound Effect
2---> -(void) PlayMusicSound: (NSString *)SoundFileName ForNumberOfLoops:(NSInteger)numLoops Extension:(NSString *)SoundExtension; // in .h file
3---> #import
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
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
{
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