Guest User

Untitled

a guest
Feb 19th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.36 KB | None | 0 0
  1. //
  2. // infopage.m
  3. // BarCodeApp
  4. //
  5. // Created by jahangir nawaz on 10/21/11.
  6. // Copyright 2011 __MyCompanyName__. All rights reserved.
  7. //
  8.  
  9. #import "infopage.h"
  10. #import "BarCodeAppViewController.h"
  11.  
  12. @implementation infopage
  13. @synthesize header;
  14. @synthesize homeurl;
  15. @synthesize hometext;
  16. @synthesize barcodeurl;
  17. @synthesize barcodetext;
  18. @synthesize gpslabel;
  19. @synthesize sw;
  20. @synthesize done;
  21.  
  22. @synthesize locationLabel;
  23. @synthesize locationSwitch;
  24. @synthesize locationstr;
  25.  
  26. @synthesize str;
  27. // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
  28. /*
  29. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  30. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  31. if (self) {
  32. // Custom initialization.
  33. }
  34. return self;
  35. }
  36. */
  37.  
  38. /*
  39. // Implement loadView to create a view hierarchy programmatically, without using a nib.
  40. - (void)loadView {
  41. }
  42. */
  43. -(void)viewWillAppear:(BOOL)animated{
  44.  
  45.  
  46.  
  47.  
  48.  
  49. }
  50.  
  51. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  52. - (void)viewDidLoad {
  53. NSLog(@"i am here")
  54. [super viewDidLoad];
  55. self.view.backgroundColor = [UIColor lightGrayColor];
  56.  
  57.  
  58. ///////////////////////header///////////////////////////
  59. header=[[UILabel alloc]initWithFrame:CGRectMake(10, 5, 300, 40)];
  60. [header setBackgroundColor:[UIColor clearColor]];
  61. [header setFont:[UIFont fontWithName:@"Helvetica-Bold" size:18 ]];
  62. [header setText: @"Enter the information provided by your webmaster below:"];
  63. [header setTextColor:[UIColor blueColor]];
  64. [header setLineBreakMode:UILineBreakModeWordWrap];
  65. [header setTextAlignment:UITextAlignmentCenter];
  66. [self.view addSubview:header];
  67.  
  68. ///////////////////////homeurl///////////////////////////
  69. homeurl=[[UILabel alloc]initWithFrame:CGRectMake(10, 50, 300, 30)];
  70. [homeurl setBackgroundColor:[UIColor clearColor]];
  71. [homeurl setTextColor:[UIColor blackColor]];
  72. [homeurl setFont:[UIFont fontWithName:@"Helvetica-Bold" size:14 ]];
  73. [homeurl setText: @"Home page URL:"];
  74. [self.view addSubview:homeurl];
  75.  
  76.  
  77. ///////////////////////hometext///////////////////////////
  78.  
  79. hometext=[[UITextField alloc]initWithFrame:CGRectMake(10, 80, 300, 30)];
  80. [hometext setBackgroundColor:[UIColor clearColor]];
  81. [hometext setTextColor:[UIColor blackColor]];
  82. //[hometext setBorderStyle:[ UITextBorderStyleRoundedRect]];
  83. hometext.borderStyle=UITextBorderStyleRoundedRect;
  84. hometext.keyboardType = UIKeyboardTypeURL;
  85. [hometext setFont:[UIFont fontWithName:@"Helvetica" size:14 ]];
  86. hometext.placeholder=@"Type or paste the URL of your web app";
  87. hometext.autocorrectionType = UITextAutocorrectionTypeNo;
  88. [self.hometext setReturnKeyType:UIReturnKeyDone];
  89. [self.hometext addTarget:self
  90. action:@selector(textFieldShouldReturn:)
  91. forControlEvents:UIControlEventEditingDidEndOnExit];
  92.  
  93. hometext.returnKeyType = UIReturnKeyDone;
  94. [self.view addSubview:hometext];
  95.  
  96. ///////////////////////barcodeurl///////////////////////////
  97.  
  98. barcodeurl=[[UILabel alloc]init];
  99. barcodeurl=[[UILabel alloc]initWithFrame:CGRectMake(10, 120, 300, 30)];
  100. [barcodeurl setBackgroundColor:[UIColor clearColor]];
  101. [barcodeurl setTextColor:[UIColor blackColor]];
  102. [barcodeurl setFont:[UIFont fontWithName:@"Helvetica-Bold" size:14 ]];
  103. [barcodeurl setText: @"Barcode lookup URL:"];
  104. [self.view addSubview:barcodeurl];
  105.  
  106. //////////////////////barcodetext///////////////////////////////
  107.  
  108. barcodetext=[[UITextField alloc]initWithFrame:CGRectMake(10, 160, 300, 30)];
  109. barcodetext.delegate = self;
  110. NSLog(@"hello");
  111.  
  112. [barcodetext setBackgroundColor:[UIColor clearColor]];
  113. [barcodetext setTextColor:[UIColor blackColor]];
  114. barcodetext.borderStyle=UITextBorderStyleRoundedRect;
  115. barcodetext.keyboardType = UIKeyboardTypeURL;
  116. [barcodetext setFont:[UIFont fontWithName:@"Helvetica" size:14 ]];
  117. barcodetext.placeholder=@"Example:http//mydomain.com/q?ean=EAN";
  118. barcodetext.autocorrectionType = UITextAutocorrectionTypeNo;
  119.  
  120. [self.barcodetext setReturnKeyType:UIReturnKeyDone];
  121. [self.barcodetext addTarget:self
  122. action:@selector(textFieldShouldReturn:)
  123. forControlEvents:UIControlEventEditingDidEndOnExit];
  124.  
  125. barcodetext.returnKeyType = UIReturnKeyDone;
  126. [self.view addSubview:barcodetext];
  127.  
  128.  
  129. gpslabel=[[UILabel alloc]init];
  130.  
  131. UIImage *img = [UIImage imageNamed:@"Done.png"];
  132.  
  133. done=[[UIButton alloc]init];
  134. // [done setTitle:@"Done" forState:UIControlStateNormal];
  135. [done setImage:img forState:UIControlStateNormal];
  136. done.backgroundColor=[UIColor clearColor];
  137. [done addTarget:self action:@selector(back)
  138. forControlEvents:UIControlEventTouchUpInside];
  139. [done setFrame:CGRectMake(130, 400, 100, 40)];
  140. [self.view addSubview:done];
  141.  
  142.  
  143.  
  144. locationController = [[MyCLController alloc] init];
  145. locationController.delegate = self;
  146. [locationController.locationManager startUpdatingLocation];
  147.  
  148. locationLabel=[[UILabel alloc]initWithFrame:CGRectMake(10, 230, 320, 30)];
  149.  
  150. // [self.view addSubview:locationLabel];
  151.  
  152. locationstr = [[NSString alloc]init];
  153. locationSwitch = [[[UISwitch alloc] initWithFrame:CGRectMake(180, 300, 320, 100)] autorelease];
  154.  
  155. if ([locationstr isEqualToString:@"ON"]) {
  156. [locationSwitch setOn:YES animated:YES];
  157. }
  158. else {
  159. [locationSwitch setOn:NO animated:YES];
  160. }
  161.  
  162. [locationSwitch addTarget:self action:@selector(locationSelector) forControlEvents:UIControlEventValueChanged];
  163.  
  164. [self.view addSubview:locationSwitch];
  165.  
  166.  
  167.  
  168. }
  169. -(void)back{
  170.  
  171. NSLog(@"hhhh");
  172. str=[NSString stringWithFormat:@"my data is %@",self.barcodetext.text];
  173. BarCodeAppViewController *ob = [[BarCodeAppViewController alloc] initWithString:str];
  174.  
  175. if(str==nil){
  176.  
  177. //NSLog(@"hhhh");
  178.  
  179. }
  180. [self presentModalViewController:ob animated:YES];
  181.  
  182.  
  183. // BarCodeAppViewController *ob = [[BarCodeAppViewController alloc] init];
  184. // [self presentModalViewController:ob animated:YES];
  185.  
  186. }
  187.  
  188.  
  189. - (void)locationUpdate:(CLLocation *)location {
  190. locationLabel.text = [location description];
  191. //locationLabel.text=[location ];
  192. }
  193.  
  194. - (void)locationError:(NSError *)error {
  195. locationLabel.text = [error description];
  196. }
  197.  
  198.  
  199. -(void)locationSelector{
  200. if(locationSwitch.on){
  201. self.locationstr = @"ON";
  202. NSLog(@"ON");
  203. }
  204. else{
  205. self.locationstr = @"OFF";
  206. NSLog(@"OFF");
  207. }
  208. }
  209. -(BOOL)textFieldShouldReturn:(UITextField *)theTextField {
  210.  
  211. if (theTextField == hometext) {
  212. [hometext resignFirstResponder];
  213. }
  214. else if (theTextField == barcodetext) {
  215. [hometext resignFirstResponder];
  216. }
  217. return YES;
  218.  
  219. }
  220. /*
  221. // Override to allow orientations other than the default portrait orientation.
  222. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  223. // Return YES for supported orientations.
  224. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  225. }
  226. */
  227.  
  228. - (void)didReceiveMemoryWarning {
  229. // Releases the view if it doesn't have a superview.
  230. [super didReceiveMemoryWarning];
  231.  
  232. // Release any cached data, images, etc. that aren't in use.
  233. }
  234.  
  235. - (void)viewDidUnload {
  236. [super viewDidUnload];
  237. // Release any retained subviews of the main view.
  238. // e.g. self.myOutlet = nil;
  239. }
  240.  
  241.  
  242. - (void)dealloc {
  243. [locationController release];
  244. [super dealloc];
  245. }
  246.  
  247.  
  248. @end
Add Comment
Please, Sign In to add comment