Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 28th, 2012  |  syntax: None  |  size: 1.69 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. displaying Wiki mobile page in UIWebView within UIPopoverController
  2. //create a UIWebView UIViewController first
  3. WikiViewController *addView = [[WikiViewController alloc] init];
  4. addView.contentSizeForViewInPopover = CGSizeMake(320.0, 480.0f);
  5.  
  6. //then create my UIPopoverController
  7. popover = [[UIPopoverController alloc] initWithContentViewController:addView];
  8. popover.delegate = self;
  9. [addView release];
  10.  
  11. //then get the popover rect
  12. CGPoint pointforPop = [self.mapView convertCoordinate:selectAnnotationCord
  13.                                         toPointToView:self.mapView];
  14. CGRect askRect = CGRectMake((int)pointforPop.x, (int)pointforPop.y+10, 1.0, 1.0);
  15. [popover presentPopoverFromRect:askRect
  16.                          inView:self.mapView
  17.        permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
  18. [self.mapView deselectAnnotation:annotation animated:YES];
  19.        
  20. - (void)viewDidLoad
  21. {
  22.  wikiWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 480.0f)];
  23.  wikiWebView.scalesPageToFit = YES;
  24.  //or No, doesn't matter, it all get larger than this
  25.  wikiWebView.delegate = self;
  26.  self.view = wikiWebView;
  27. }
  28.        
  29. - (void) webViewDidFinishLoad:(UIWebView *)webView
  30. {
  31. if (!alreadyReload)
  32. {
  33.     NSString *webHTML = [NSString stringWithContentsOfURL:webView.request.URL encoding:NSUTF8StringEncoding error:NULL];
  34.     NSRange range = [webHTML rangeOfString:@"device-width"];
  35.     if ((range.location!=NSNotFound)&&(range.length != 0))
  36.     {
  37.         webHTML = [webHTML stringByReplacingOccurrencesOfString:@"device-width" withString:@"whatever width you need" options:0 range:range];
  38.         [webView loadHTMLString:webHTML baseURL:wikiWebView.request.URL];
  39.         alreadyReload = YES;
  40.     }
  41. }
  42. }