Advertisement
Guest User

Untitled

a guest
Feb 1st, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (id)init {
  2.     if (self = [super init]) {
  3.    
  4.             web = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
  5.    
  6.      
  7.        
  8.         url=[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]
  9.                                                                  pathForResource:@"doc1" ofType:@"html"]isDirectory:NO]];
  10.        
  11.         url1=[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]
  12.                                                                  pathForResource:@"doc2" ofType:@"html"]isDirectory:NO]];
  13.        
  14.  
  15.       arr =[[NSArray alloc]initWithObjects:url,url1, nil];
  16.        
  17.  
  18.     }
  19.     return self;
  20.    
  21.    
  22. }
  23.  
  24. - (void)dealloc {
  25.     [images release];
  26.     [super dealloc];
  27. }
  28.  
  29. #pragma mark LeavesViewDataSource methods
  30.  
  31. - (NSUInteger) numberOfPagesInLeavesView:(LeavesView*)leavesView {
  32.     return arr.count;
  33. }
  34.  
  35. - (void) renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx {
  36.      [web loadRequest:[arr objectAtIndex:index]];
  37.     CGSize screensize = CGSizeMake(320,480);
  38.    
  39.     UIGraphicsBeginImageContext(screensize);
  40.     CGContextRef context = UIGraphicsGetCurrentContext();
  41.     CGFloat scalingFactor = screensize.width/web.frame.size.width;
  42.     CGContextScaleCTM(context, scalingFactor,scalingFactor);
  43.  
  44.     [web.layer renderInContext: ctx];
  45.       [self.view addSubview:web];
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement