Вы находитесь на странице: 1из 17

ThirdViewController.

4/14/12 3:53 PM

// // // // // // //

ThirdViewController.m patent pro Created by Amit Barman on 4/12/12. Copyright (c) 2012 Apollo Software. All rights reserved.

#import "ThirdViewController.h" @implementation ThirdViewController @synthesize wWw,draw; NSString *str; int nextVal; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *) nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { self.title = NSLocalizedString(@"Search Patents", @"Search Patents") ; self.tabBarItem.image = [UIImage imageNamed:@"second"]; } return self; } - (IBAction)nextValue { if (nextVal > 25) nextVal = -1; nextVal++; NSString *tit = [NSString stringWithFormat:@"Search Results for %@", [patentName text]]; [patentTitle setText:tit]; patentTitle.text = tit; label2.text = @"searching patents..."; activityIndicator.hidden = 0;label2.hidden=0; [activityIndicator startAnimating]; [self performSelector:@selector(searchPatent) withObject:nil afterDelay: 0.01]; } - (IBAction)prevValue { if (nextVal == 0) nextVal = 1; nextVal--; NSString *tit = [NSString stringWithFormat:@"Search Results for %@", [patentName text]]; [patentTitle setText:tit];
Page 1 of 17

ThirdViewController.m

4/14/12 3:53 PM

patentTitle.text = tit; label2.text = @"searching patents..."; activityIndicator.hidden = 0;label2.hidden=0; [activityIndicator startAnimating]; [self performSelector:@selector(searchPatent) withObject:nil afterDelay: 0.01]; } +(BOOL) isIPad { BOOL isIPad=NO; NSString* model = [UIDevice currentDevice].model; if ([model rangeOfString:@"iPad"].location != NSNotFound) { return YES; } return isIPad; } - (void)messageComposeViewController:(MFMessageComposeViewController *) controller didFinishWithResult:(MessageComposeResult)result { //message.hidden = NO; switch (result) { case MessageComposeResultCancelled: // message.text = @"Result: canceled"; NSLog(@"Result: canceled"); break; case MessageComposeResultSent: // message.text = @"Result: sent"; NSLog(@"Result: sent"); break; case MessageComposeResultFailed: // message.text = @"Result: failed"; NSLog(@"Result: failed"); break; default: // message.text = @"Result: not sent"; NSLog(@"Result: not sent"); break; } [self dismissModalViewControllerAnimated:YES]; } - (IBAction) smsLoad { label2.text = @"loading SMS..."; activityIndicator.hidden = 0;label2.hidden=0; [activityIndicator startAnimating]; [self performSelector:@selector(sms) withObject:nil afterDelay:0.01]; } - (IBAction)loadPatent
Page 2 of 17

ThirdViewController.m

4/14/12 3:53 PM

{ label2.text = @"loading patent..."; activityIndicator.hidden = 0;label2.hidden=0; [activityIndicator startAnimating]; [self performSelector:@selector(loadPatent1) withObject:nil afterDelay: 0.01]; } - (IBAction)copyPatent { NSString *outputText = [[NSString alloc] initWithFormat:@"%@: URL:%@ Images:%@",patentTitle.text,lbllink.text,lblImage.text]; UIPasteboard *appPasteBoard = [UIPasteboard generalPasteboard]; appPasteBoard.persistent = YES; [appPasteBoard setString:outputText]; UIAlertView *fullAlert = [[UIAlertView alloc] initWithTitle:@"patent pro: Patent Info" message:@"Patent Info link copied to clipboard" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil]; [fullAlert show]; } - (IBAction) mailLoad { label2.text = @"loading e-mail..."; activityIndicator.hidden = 0;label2.hidden=0; [activityIndicator startAnimating]; [self performSelector:@selector(mail) withObject:nil afterDelay:0.01]; } - (void) mail { @try { NSString *urlpath = [[NSString alloc] initWithFormat:@"%@", [patentDesc text]]; int numLtrs = [urlpath length];

if (numLtrs > 1) { NSString *urlpath = [[NSString alloc] initWithFormat:@"%@", [patentDesc text]]; NSString *urlString = [NSString stringWithFormat:urlpath]; NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] ; NSMutableURLRequest* request = [[[NSMutableURLRequest alloc] initWithURL:url] autorelease]; [request setValue:@"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv: 2.0.1) Gecko/20100101 Firefox/4.0.1" forHTTPHeaderField:@"UserAgent"];

Page 3 of 17

ThirdViewController.m

4/14/12 3:53 PM

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; NSString *subText = [[NSString alloc] initWithFormat:@"patent pro: % @",patentTitle.text]; NSString *msgText = [[NSString alloc] initWithFormat:@"<a href=\"%@ \">Link to Patent</a> | <a href=\"%@\">Link to Image</a><br>%@", lbllink.text,lblImage.text,patentDesc.text]; NSLog(@"LINKO: %@", lblInfo.text); NSURL * imageURL = [NSURL URLWithString:lblInfo.text]; NSData *data = [NSData dataWithContentsOfURL:imageURL]; [picker addAttachmentData:data mimeType:@"application/tiff" fileName:@"drawimage.tif"]; if (!draw.hidden) { msgText = [[NSString alloc] initWithFormat:@"<a href=\"%@\">Link to Patent</a> | <a href=\"%@\">Link to Image</a><br>", lbllink.text,lblImage.text]; } [picker setSubject:subText]; [picker setMessageBody:msgText isHTML:YES]; picker.navigationBar.barStyle = UIBarStyleDefault; [self presentModalViewController:picker animated:YES]; } else { UIAlertView *fullAlert = [[UIAlertView alloc] initWithTitle:@"patent pro: Patent Info" message:@"Patent Info not available or results do not exist." delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil]; nextVal = 0; [fullAlert show]; } } @catch (NSException *e) { } activityIndicator.hidden = 1;label2.hidden=1; } - (void) sms {
Page 4 of 17

ThirdViewController.m

4/14/12 3:53 PM

NSString *urlpath = [[NSString alloc] initWithFormat:@"%@", [patentDesc text]]; int numLtrs = [urlpath length]; if (numLtrs > 1) { @try { NSString *outputText = [[NSString alloc] initWithFormat:@"%@: Patent:%@",patentTitle.text,lbllink.text]; if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"sms:11111"]]){ //do stuff for sms MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init]; picker.messageComposeDelegate = self; //picker.recipients = [NSArray arrayWithObject:@"123456789"] ; // your recipient number or self for testing picker.body = outputText; [activityIndicator stopAnimating]; [self presentModalViewController:picker animated:YES]; [picker release]; }else{ [activityIndicator stopAnimating]; NSLog(@"I don't suport sms"); UIAlertView *fullAlert = [[UIAlertView alloc] initWithTitle: @"patent pro: SMS" message:@"Sorry. I don't support SMS on this device." delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil]; [fullAlert show]; } } @catch (NSException *e) { UIAlertView *fullAlert = [[UIAlertView alloc] initWithTitle: @"patent pro: SMS" message:@"Sorry. I don't support SMS on this device." delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil]; [fullAlert show]; } } else { UIAlertView *fullAlert = [[UIAlertView alloc] initWithTitle: @"patent pro: Patent Info" message:@"Patent Info not available or results do not exist." delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil]; nextVal = 0;

Page 5 of 17

ThirdViewController.m

4/14/12 3:53 PM

[fullAlert show]; } [activityIndicator stopAnimating]; activityIndicator.hidden = 1;label2.hidden=1; } - (void) loadPatent1 { wWw.hidden = false; NSString *request = [NSString stringWithFormat:@"http://www.fatsecret. com/calories-nutrition/search?q=%@&pg=%d",[patentName text],nextVal] ; NSString *escapedUrl = [request stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; NSURL *URL = [NSURL URLWithString:escapedUrl]; NSError *error; NSString *XML = [NSString stringWithContentsOfURL:URL encoding: NSASCIIStringEncoding error:&error]; @try { [patentDesc setText:@""]; NSString *link = [[[[XML componentsSeparatedByString:@"prominent\" href=\""] objectAtIndex:1] componentsSeparatedByString:@"\""] objectAtIndex:0]; str = [[[[XML componentsSeparatedByString:@"- Calories"] objectAtIndex:1] componentsSeparatedByString:@"| Protein: "] objectAtIndex:0]; NSString *str2 = [NSString stringWithFormat:@"Calories%@",str]; [lblInfo setText:str2]; NSLog(@"Request: %@", str); NSString *request = [NSString stringWithFormat:@"http://www. fatsecret.com/calories-nutrition%@",link]; [lbllink setText:request]; NSLog(@"Request: %@", request); NSString *escapedUrl = [request stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; NSURL *URL = [NSURL URLWithString:escapedUrl];

Page 6 of 17

ThirdViewController.m

4/14/12 3:53 PM

NSError *error; NSString *XML = [NSString stringWithContentsOfURL:URL encoding: NSASCIIStringEncoding error:&error]; NSString *link2 = [[[[XML componentsSeparatedByString:@"<div class= \"nutpanel\">"] objectAtIndex:1] componentsSeparatedByString: @"Your daily values "] objectAtIndex:0]; NSString *chart = [[[[XML componentsSeparatedByString: @"cfp_breakdown_container\" style=\"width:255px\">"] objectAtIndex:1] componentsSeparatedByString:@"</table>"] objectAtIndex:0]; chart = [chart stringByReplacingOccurrencesOfString:@"/static/" withString:@"http://www.fatsecret.com/static/"]; NSString *title = [[[[XML componentsSeparatedByString:@"<title>"] objectAtIndex:1] componentsSeparatedByString:@"</title>"] objectAtIndex:0]; NSLog(@"%@", link2); NSLog(@"%@", title); title = [title stringByReplacingOccurrencesOfString:@"&quot;" withString:@"\""]; title = [title stringByReplacingOccurrencesOfString:@"&amp;" withString:@"&"]; [patentTitle setText:title]; //http://www.fatsecret.com/static/css/default_16.css?v=3 // NSString* wwwTextAppend = [NSString stringWithFormat:@"<link rel=\ "stylesheet\" href=\"http://www.fatsecret.com/static/css/ default_16.css?v=3\" type=\"text/css\"/>"]; NSString* wwwText = [NSString stringWithFormat:@"%@<font face=\ "Arial\">%@</font><br><br>%@", wwwTextAppend,link2,chart]; [patentDesc setText:wwwText]; [wWw loadHTMLString:wwwText baseURL:nil]; //[wWw loadHTMLString:translation baseURL:nil]; NSLog(@"%@",request); } @catch (NSException *e) { NSString *answer = @"Invalid Query."; [self performSelector:@selector(clear) withObject:nil afterDelay:0.01]; NSLog(@"%@", answer);
Page 7 of 17

ThirdViewController.m

4/14/12 3:53 PM

//[patentDesc setText:answer]; UIAlertView *fullAlert = [[UIAlertView alloc] initWithTitle: @"patent pro: Patent Info" message:@"Patent Info not available or results do not exist." delegate:nil cancelButtonTitle: @"Close" otherButtonTitles:nil]; [fullAlert show]; nextVal = 0; NSLog(@"Exception: %@", e); } activityIndicator.hidden = 1;label2.hidden=1; [patentName resignFirstResponder]; } -(IBAction)dismissKeyboard: (id)sender { [sender resignFirstResponder]; NSString *urlpath = [[NSString alloc] initWithFormat:@"%@", [patentName text]]; int numLtrs = [urlpath length]; nextVal = 0; if (numLtrs > 1) { label2.text = @"searching patents..."; activityIndicator.hidden = 0;label2.hidden=0; [activityIndicator startAnimating]; [self performSelector:@selector(search) withObject:nil afterDelay:0.01]; } } - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { [self dismissModalViewControllerAnimated:YES]; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (IBAction)search { nextVal = 0; NSString *tit = [NSString stringWithFormat:@"Search Results for %@", [patentName text]];
Page 8 of 17

ThirdViewController.m

4/14/12 3:53 PM

[patentTitle setText:tit]; patentTitle.text = tit; label2.text = @"searching patents..."; activityIndicator.hidden = 0;label2.hidden=0; [activityIndicator startAnimating]; [self performSelector:@selector(searchPatent) withObject:nil afterDelay: 0.01]; } - (void)loadPics { NSString *tit1 = [NSString stringWithFormat:@"%@",lblImage.text]; @try { NSString *request1 = [NSString stringWithFormat:@"%@",tit1]; request1 = [request1 stringByReplacingOccurrencesOfString:@"%2F" withString:@"/"]; request1 = [request1 stringByReplacingOccurrencesOfString:@"%22" withString:@"\""]; NSLog(@"Request*****good: %@", request1); NSString *escapedUrl1 = [request1 stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; NSURL *URL1 = [NSURL URLWithString:escapedUrl1]; NSError *error; NSString *XML1 = [NSString stringWithContentsOfURL:URL1 encoding: NSASCIIStringEncoding error:&error]; NSLog(@"Request*****XMLLLL: %@", XML1); NSString *image1 = [[[[XML1 componentsSeparatedByString:@"<embed src =\""] objectAtIndex:1] componentsSeparatedByString:@"IDKey"] objectAtIndex:0]; NSString *IDKey = [[[[XML1 componentsSeparatedByString:@"IDKey="] objectAtIndex:1] componentsSeparatedByString:@"&"] objectAtIndex:0]; NSString* pagen = [NSString stringWithFormat:@"Page %g", imagePage. value]; IDKey=[IDKey substringToIndex:12]; pageNum.text = pagen; NSString* wwwTextAppend1 = [NSString stringWithFormat:@"http:// patimg1.uspto.gov"];
Page 9 of 17

ThirdViewController.m

4/14/12 3:53 PM

NSString* wwwText1 = [NSString stringWithFormat:@"%@%@IDKey=%@& ImgFormat=tif&PageNum=%g", wwwTextAppend1,image1,IDKey,imagePage .value]; wwwText1 = [wwwText1 stringByReplacingOccurrencesOfString:@" " withString:@""]; lblInfo.text = wwwText1; NSLog(@"Request*****WWW: %@", wwwText1); //lblImage.text = wwwText1; [draw loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString: wwwText1]]]; draw.hidden = false; // NSLog(@"%@",request); } @catch (NSException *e) { NSString *answer = @"Invalid Query."; //[self performSelector:@selector(clear) withObject:nil afterDelay: 0.01]; NSLog(@"%@", answer); //[patentDesc setText:answer]; UIAlertView *fullAlert = [[UIAlertView alloc] initWithTitle:@"patent pro: Patent Info" message:@"Patent Info not available or results do not exist." delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil]; [fullAlert show]; NSLog(@"Exception: %@", e); } activityIndicator.hidden = 1;label2.hidden=1; } - (IBAction)increm { label2.text = @"loading image/drawing..."; activityIndicator.hidden = 0;label2.hidden=0; [activityIndicator startAnimating]; [self performSelector:@selector(loadPics) withObject:nil afterDelay:0.01 ]; } - (IBAction)loadPatentPics { if (draw.hidden) { imagePage.hidden = false; pageNum.hidden = false; imagePage.value = 1; pageNum.text = @"Page 1"; // draw.hidden = false;

Page 10 of 17

ThirdViewController.m

4/14/12 3:53 PM

[self.view bringSubviewToFront:toolbar]; [self.view bringSubviewToFront:label2]; [self.view bringSubviewToFront:activityIndicator]; label2.text = @"loading image/drawing..."; activityIndicator.hidden = 0;label2.hidden=0; [activityIndicator startAnimating]; [self performSelector:@selector(loadPics) withObject:nil afterDelay: 0.01]; } else { pageNum.hidden = true; imagePage.hidden = true; draw.hidden = true; } } - (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { if (navigationType == UIWebViewNavigationTypeLinkClicked) { NSURL *URL = [request URL]; NSString *urlString = [URL absoluteString]; NSLog(@"url is: %@ ", urlString); if([urlString hasPrefix:@"http"]) { NSString *tit = [NSString stringWithFormat:@"%@",urlString]; @try { [patentDesc setText:@""]; NSString *request = [NSString stringWithFormat:@"%@",tit]; request = [request stringByReplacingOccurrencesOfString:@"%2F" withString:@"/"]; request = [request stringByReplacingOccurrencesOfString:@"%22" withString:@"\""]; [lbllink setText:request]; NSLog(@"Request*****good: %@", request); NSString *escapedUrl = [request stringByAddingPercentEscapesUsingEnc oding:NSUTF8StringEncoding]; NSURL *URL = [NSURL URLWithString:escapedUrl];

Page 11 of 17

ThirdViewController.m

4/14/12 3:53 PM

NSError *error; NSString *XML = [NSString stringWithContentsOfURL:URL encoding: NSASCIIStringEncoding error:&error]; //http://patimg1.uspto.gov/.DImg?Docid=RE043311&PageNum=1&IDKey=7DE2D51 C1FE6&ImgFormat=tif NSLog(@"Request*****XMLLLL: %@", XML); NSString *desc = [[[[XML componentsSeparatedByString:@"</FONT></ TD></TR></TABLE>"] objectAtIndex:1] componentsSeparatedByString:@"* * * * *</B></CENTER>"] objectAtIndex:0]; NSString *image = [[[[XML componentsSeparatedByString:@"order. gif"] objectAtIndex:1] componentsSeparatedByString:@"[Image ]"] objectAtIndex:0];

image = [[[[image componentsSeparatedByString:@"href="] objectAtIndex:1] componentsSeparatedByString:@">"] objectAtIndex:0]; image = [image stringByReplacingOccurrencesOfString:@"%3A" withString:@":"]; image = [image stringByReplacingOccurrencesOfString:@"%3F" withString:@"?"]; image = [image stringByReplacingOccurrencesOfString:@"%3D" withString:@"="]; image = [image stringByReplacingOccurrencesOfString:@"%2F" withString:@"/"]; image = [image stringByReplacingOccurrencesOfString:@"%22" withString:@"\""]; image = [image stringByReplacingOccurrencesOfString:@"%2526" withString:@"&"]; image = [image stringByReplacingOccurrencesOfString:@"%252B" withString:@"+"]; image = [image stringByReplacingOccurrencesOfString:@"%252522" withString:@"'"]; btnImage.enabled = TRUE; lblImage.text = image; NSLog(@"Request*****desc: %@", desc); desc = [desc stringByReplacingOccurrencesOfString:@"HREF=\"/" withString:@"HREF=\"http://patft.uspto.gov/"]; desc = [desc stringByReplacingOccurrencesOfString:@"href=\"/" withString:@"href=\"http://patft.uspto.gov/"]; NSString *title = [[[[XML componentsSeparatedByString:@"<TITLE>" ] objectAtIndex:1] componentsSeparatedByString:@"</TITLE>"] objectAtIndex:0]; NSLog(@"Request*****title: %@", title); NSLog(@"%@", title); [patentTitle setText:title];
Page 12 of 17

ThirdViewController.m

4/14/12 3:53 PM

NSString* wwwTextAppend = [NSString stringWithFormat:@""]; NSString* wwwText = [NSString stringWithFormat:@"%@%@* * * * *</ B></CENTER>", wwwTextAppend,desc]; [patentDesc setText:wwwText]; [wWw loadHTMLString:wwwText baseURL:nil]; NSLog(@"%@",request); } @catch (NSException *e) { NSString *answer = @"Invalid Query."; [self performSelector:@selector(clear) withObject:nil afterDelay:0.01]; NSLog(@"%@", answer); //[patentDesc setText:answer]; UIAlertView *fullAlert = [[UIAlertView alloc] initWithTitle:@"patent pro: Patent Info" message: @"Patent Info not available or results do not exist ." delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil]; nextVal = 0; [fullAlert show]; NSLog(@"Exception: %@", e); } activityIndicator.hidden = 1;label2.hidden=1; } } return YES; } - (void)searchPatent { btnImage.enabled = FALSE; draw.hidden = true; imagePage.hidden = true; pageNum.hidden = true; wWw.hidden = false; NSString *request = [NSString stringWithFormat:@"http://patft.uspto. gov/netacgi/nph-Parser?Sect1=PTO2&Sect2=HITOFF&p=1&u=/netahtm/PTO /search-bool.html&r=0&f=S&l=50&TERM1=%@&FIELD1=&co1=AND&TERM2=& FIELD2=&d=PALL",[patentName text]]; [lbllink setText:request]; [lblInfo setText:@"No Info"]; NSString *escapedUrl = [request
Page 13 of 17

ThirdViewController.m

4/14/12 3:53 PM

stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; NSURL *URL = [NSURL URLWithString:escapedUrl]; NSError *error; NSString *XML = [NSString stringWithContentsOfURL:URL encoding: NSASCIIStringEncoding error:&error]; @try { [patentDesc setText:@""]; NSString *link = [[[[XML componentsSeparatedByString:@"<TABLE><TR>"] objectAtIndex:1] componentsSeparatedByString:@"</TABLE>"] objectAtIndex:0]; link = [link stringByReplacingOccurrencesOfString:@"HREF=/" withString:@"href=http://patft.uspto.gov/"]; link = [link stringByReplacingOccurrencesOfString:@"src=\"/" withString:@"src=\"http://patft.uspto.gov/"]; NSString* wwwTextAppend = [NSString stringWithFormat:@"<table><tr>"] ; NSString *HTML = [NSString stringWithFormat:@"%@%@</table>", wwwTextAppend,link]; [patentDesc setText:HTML]; [wWw loadHTMLString:HTML baseURL:nil]; NSLog(@"%@",request); } @catch (NSException *e) { NSString *answer = @"Invalid Query."; [self performSelector:@selector(clear) withObject:nil afterDelay: 0.01]; NSLog(@"%@", answer); //[patentDesc setText:answer]; UIAlertView *fullAlert = [[UIAlertView alloc] initWithTitle: @"patent pro: Patent Info" message:@"Patent Info not available or results do not exist." delegate:nil cancelButtonTitle: @"Close" otherButtonTitles:nil]; nextVal = 0; [fullAlert show]; NSLog(@"Exception: %@", e); } activityIndicator.hidden = 1;label2.hidden=1; [patentName resignFirstResponder]; }

Page 14 of 17

ThirdViewController.m

4/14/12 3:53 PM

- (IBAction)clear { draw.hidden = true; imagePage.hidden = true; pageNum.hidden = true; patentDesc.text = @""; patentTitle.text = @"U.S. Patent Search"; patentName.text = @""; wWw.Hidden = true; nextVal = 0; NSString* wwwText = @""; [patentName resignFirstResponder]; [wWw loadHTMLString:wwwText baseURL:nil]; } - (void)actionSheet:(UIActionSheet *)popup clickedButtonAtIndex:(NSInteger) buttonIndex { switch (popup.tag) { case 1: { NSString *outputText = [[NSString alloc] initWithFormat:@"%@: URL:%@",patentTitle.text,lbllink.text]; UIPasteboard *appPasteBoard = [UIPasteboard generalPasteboard]; appPasteBoard.persistent = YES; [appPasteBoard setString:outputText];

switch (buttonIndex) { case 0: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.facebook.com/dialog/feed ?app_id=118830838249927&redirect_uri=http%3A//www. facebook.com/apps/application.php?id=118830838249927 &to&message=@[199116963445570%3A2048%3ACHANGE_OR_ALT ER_THIS_WITH_YOUR_OWN_YOUR_OWN_MESSAGE]&display= touch"]]; break; case 1: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.myspace.com/Modules/ PostTo/Pages/?t=patent%20pro:click%20paste%20on%20te xt%20box&c=message&l=1"]]; break; case 2: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://twitter.com/intent/tweet?
Page 15 of 17

ThirdViewController.m

4/14/12 3:53 PM

source=webclient&text="]]; break; case 3: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://m.google.com/app/plus/x/976f bnrafv3e/?content=Paste%20Here&v=compose&pli=1&login =1"]]; case 4: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.tumblr.com/share"]]; break; default: break; } break; } default:break; } } - (IBAction)share { UIActionSheet *popup = [[UIActionSheet alloc] initWithTitle:@"Select Sharing option (the patent name and url info is copied to your clipboard. Click the textbox and select paste):" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles: @"Share on Facebook", @"Share on MySpace", @"Share on Twitter", @"Share on Google+", @"Share on tumblr", nil]; [[[popup valueForKey:@"_buttons"] objectAtIndex:0] setImage:[UIImage imageNamed:@"facebook-icon.png"] forState:UIControlStateNormal]; [[[popup valueForKey:@"_buttons"] objectAtIndex:1] setImage:[UIImage imageNamed:@"myspace-icon.png"] forState:UIControlStateNormal]; [[[popup valueForKey:@"_buttons"] objectAtIndex:2] setImage:[UIImage imageNamed:@"twitter-icon.png"] forState:UIControlStateNormal]; [[[popup valueForKey:@"_buttons"] objectAtIndex:3] setImage:[UIImage imageNamed:@"google-icon.png"] forState:UIControlStateNormal]; [[[popup valueForKey:@"_buttons"] objectAtIndex:4] setImage:[UIImage imageNamed:@"Tumblr-icon.png"] forState:UIControlStateNormal]; popup.tag = 1; [popup showInView:[UIApplication sharedApplication].keyWindow]; //[popup release]; }
Page 16 of 17

ThirdViewController.m

4/14/12 3:53 PM

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (motion == UIEventSubtypeMotionShake) { } } #pragma mark - View lifecycle -(BOOL)canBecomeFirstResponder { return YES; } -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self becomeFirstResponder]; } - (void)viewWillDisappear:(BOOL)animated { [self resignFirstResponder]; [super viewWillDisappear:animated]; } - (void)viewDidLoad { activityIndicator.hidden = true; nextVal = 0; [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque]; wWw.delegate = self; [super viewDidLoad]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown ); } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } @end

Page 17 of 17

Вам также может понравиться