1. /*in my viewDidLoad in the details.m , the class containing the image and web view i am relying on viewDidLoad as follows : */
  2. - (void)viewDidLoad
  3. {
  4. // [self loadHtmlNewFontSize:sizeFontFromStepper];
  5. /* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
  6. /* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
  7. /* ---------------------------------------------------------------------------------------------------- IF the landscape mode is on loaded from the beginning !!!! ------------------------------------------------------------------------------------------------------ */
  8. /* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
  9. /* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
  10. if(LoadedRotated == YES){
  11. NSLog(@"The view is loaded rotated");
  12. Rot = YES;
  13. }
  14. /* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
  15. /* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
  16. /* ------------------------------------------------------------------------------------------------------------------------- IF the Portrait mode is on !!!! ----------------------------------------------------------------------------------------------------------- */
  17. /* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
  18. /* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
  19. NSLog(@"In the viewDidLoad this is the current value of the textFontSize %d" , textFontSize);
  20. if(Rot == NO){
  21. NewWidth2 = NewWidth;
  22. NewHeight2 = NewHeight;
  23. sizeFontFromStepper.minimumValue = 40;
  24. sizeFontFromStepper.maximumValue = 50;
  25. sizeFontFromStepper.value = 40;
  26. NSLog(@"The bool value of Rot is NO");
  27. NSString * htmlString = [NSString stringWithFormat:@"\
  28. <html>\
  29. <body>\
  30. <p style = 'font-size:40px;'> %@ <\p>\
  31. </body>\
  32. </html>",authorNAme];
  33. [self.WebV setScalesPageToFit:YES];
  34. [self.WebV loadHTMLString:htmlString baseURL:nil];
  35. NSString* extension = @"png";
  36. NSString* strRR = [NSString stringWithFormat:@"%@.%@", authorNAme2,extension];
  37. NSLog(@"This is the strRR variable %@ " , strRR);
  38. NSString *path = [[NSBundle mainBundle] bundlePath];
  39. //NSLog(@"This is the path %@", path);
  40. NSURL *baseURL = [NSURL fileURLWithPath:path];
  41. // NSLog(@"this is the base URL %@",baseURL);
  42. NSString *cachePath = [NSString stringWithFormat:@"%@/%@", path,strRR];
  43. NSLog(@"this is the cachPath variable %@" , cachePath);
  44. NSFileManager *fm = [NSFileManager defaultManager];
  45. NSLog(@"!!!!!!!!!!!!!!!!!!!!!!this is the image width %.6f and the image Height %.6f In the landscape mode !!!!!!!!!!!!!!!!!!!" , ImView.frame.size.width,ImView.frame.size.height);
  46. if(FirstLoad){
  47. ImView.frame = CGRectMake(150, 430, ImView.frame.size.width,ImView.frame.size.height);
  48. FirstLoad = NO;
  49. }
  50. else{
  51. ImView.frame = CGRectMake(150, 430, NewWidth,NewHeight);
  52. }
  53. if([fm fileExistsAtPath:cachePath])
  54. {
  55. ImView.image = [UIImage imageNamed:strRR];
  56. ImView.contentMode = UIViewContentModeScaleAspectFit;
  57. NSLog(@"file exists");
  58. // NSString * htmlString2 = [NSString stringWithFormat:@"<img src='%@' height='330' width='450' >" , strRR];
  59. // NSLog(@"This is the Strr %@ " , strRR );
  60. // WebV2.opaque = NO;
  61. // WebV2.backgroundColor = [UIColor clearColor];
  62. // [self.WebV2 loadHTMLString:htmlString2 baseURL:baseURL];
  63. // WebV3.backgroundColor = [UIColor whiteColor];
  64. }
  65. else
  66. {
  67. NSLog(@"file doest not exist");
  68. // NSString * htmlString2 = [NSString stringWithFormat:@"<img src='aa.png' height='330' width='450' >"];
  69. // WebV2.opaque = NO;
  70. // WebV2.backgroundColor = [UIColor clearColor];
  71. // [self.WebV2 loadHTMLString:htmlString2 baseURL:baseURL];
  72. // WebV3.backgroundColor = [UIColor whiteColor];
  73. // ImView.image = [UIImage imageNamed:@"aa.png"];
  74. //ll ImView.contentMode = UIViewContentModeScaleAspectFit;
  75. }
  76. }
  77. /* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
  78. /* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
  79. /* ------------------------------------------------------------------------------------------------------------------------- IF the landscape mode is on !!!! ----------------------------------------------------------------------------------------------------------- */
  80. /* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
  81. /* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
  82. else{
  83. sizeFontFromStepper.minimumValue = 25;
  84. sizeFontFromStepper.maximumValue = 35;
  85. sizeFontFromStepper.value = 25;
  86. NSLog(@"The bool value of Rot is YES");
  87. NSString * htmlString = [NSString stringWithFormat:@"\
  88. <html>\
  89. <body>\
  90. <p style = 'font-size:25px;'> %@ <\p>\
  91. </body>\
  92. </html>",authorNAme];
  93. [self.WebV setScalesPageToFit:YES];
  94. [self.WebV loadHTMLString:htmlString baseURL:nil];
  95. NSString* extension = @"png";
  96. NSString* strRR = [NSString stringWithFormat:@"%@.%@", authorNAme2,extension];
  97. NSLog(@"This is the strRR variable %@ " , strRR);
  98. NSString *path = [[NSBundle mainBundle] bundlePath];
  99. //NSLog(@"This is the path %@", path);
  100. NSURL *baseURL = [NSURL fileURLWithPath:path];
  101. // NSLog(@"this is the base URL %@",baseURL);
  102. NSString *cachePath = [NSString stringWithFormat:@"%@/%@", path,strRR];
  103. NSLog(@"this is the cachPath variable %@" , cachePath);
  104. NSFileManager *fm = [NSFileManager defaultManager];
  105. if([fm fileExistsAtPath:cachePath])
  106. {
  107. ImView.image = [UIImage imageNamed:strRR];
  108. ImView.contentMode = UIViewContentModeScaleAspectFit;
  109. NSLog(@"file exists");
  110. // NSString * htmlString2 = [NSString stringWithFormat:@"<img src='%@' height='330' width='450' >" , strRR];
  111. // NSLog(@"This is the Strr %@ " , strRR );
  112. // WebV2.opaque = NO;
  113. // WebV2.backgroundColor = [UIColor clearColor];
  114. // [self.WebV2 loadHTMLString:htmlString2 baseURL:baseURL];
  115. // WebV3.backgroundColor = [UIColor whiteColor];
  116. }
  117. else
  118. {
  119. NSLog(@"file does not exist");
  120. // NSString * htmlString2 = [NSString stringWithFormat:@"<img src='aa.png' height='330' width='450' >"];
  121. // WebV2.opaque = NO;
  122. // WebV2.backgroundColor = [UIColor clearColor];
  123. // [self.WebV2 loadHTMLString:htmlString2 baseURL:baseURL];
  124. // WebV3.backgroundColor = [UIColor whiteColor];
  125. // ImView.image = [UIImage imageNamed:@"aa.png"];
  126. // ImView.contentMode = UIViewContentModeScaleAspectFit;
  127. }
  128. // UIAlertView *messageAlert = [[UIAlertView alloc]
  129. // initWithTitle:@"New Width and height!" message:(@"This is the new value of width %.6u and height %.6u" , NewWidth, NewHeight) delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
  130. //
  131. // [messageAlert show];
  132. NSLog(@"!!!!!!!!!!!!!!!!!!!!!!this is the image width %.6f and the image Height %.6f In the landscape mode !!!!!!!!!!!!!!!!!!!" , ImView.frame.size.width,ImView.frame.size.height);
  133. ImView.frame = CGRectMake(280, 350, (NewWidth - (NewWidth /6)) ,(NewHeight - (NewHeight /6)));
  134. WebV.contentMode = UIViewContentModeScaleAspectFit;
  135. WebV.scalesPageToFit = YES;
  136. WebV.autoresizingMask = (UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth );
  137. // ImView.contentMode = UIViewContentModeScaleAspectFit;
  138. // ImView.autoresizingMask = ( UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
  139. //
  140. [super viewDidLoad];
  141. //textFontSize = sizeFontFromStepper.value;
  142. NSLog(@"this is the uistepper value %d", textFontSize);
  143. //self.labelText.text = authorNAme;text // NSInteger *fontSize = 100;
  144. }
  145. self.text2.text = authorNAme2;
  146. /* //////////////////////////////////////////// This is where the label text APPearsssssssss /////////////////////////// */
  147. NSLog(@"Everything is ok now !");
  148. }
  149. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  150. /*And in the MyTabController.m class, the subclass that controls the rotation of tab bar controller*/
  151. BOOL LoadedRotated = NO;
  152. NSUInteger *cal = 0;
  153. -(void)viewDidLoad{
  154. // [self willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientationLandscapeRight) duration:1];
  155. }
  156. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  157. return YES;
  158. }
  159. - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
  160. if(interfaceOrientation == UIInterfaceOrientationPortrait){
  161. // interfaceOrientation = UIInterfaceOrientationPortrait;
  162. NSLog(@"Interface loaded in portrait mode");
  163. LoadedRotated = NO;
  164. Rot = NO;
  165. }
  166. if(interfaceOrientation == UIInterfaceOrientationLandscapeRight){
  167. // interfaceOrientation = UIInterfaceOrientationPortrait;
  168. if(cal == 0){
  169. LoadedRotated = YES;
  170. cal++;
  171. }
  172. Rot = YES;
  173. }
  174. if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft){
  175. Rot = YES;
  176. NSLog(@"This is the landscape left mode");
  177. }
  178. }
Comments powered by Disqus