redribben

code comparison

Nov 4th, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  CalendarViewController.m
  3. //  Радио СВЕТ
  4. //
  5. //  Created by Bogdan Michalchuk on 10/24/14.
  6. //  Copyright (c) 2014 Радио CBET. All rights reserved.
  7. //
  8.  
  9. #import "CalendarViewController.h"
  10.  
  11.  
  12. @interface CalendarViewController ()
  13. @property (copy, nonatomic) UIImage *image;
  14. @property (weak, nonatomic) IBOutlet UIButton *backButton;
  15.  
  16. @end
  17.  
  18. @implementation CalendarViewController {}
  19.  
  20. @synthesize scheduleImage;
  21.  
  22. - (BOOL)prefersStatusBarHidden {
  23.     return YES;
  24. }
  25.  
  26. - (void)viewDidLoad {
  27.     [super viewDidLoad];
  28. //    [self displayImage];
  29.     [self addScrollView];
  30.     [self.view bringSubviewToFront:_backButton];
  31. //    UIImage *background = [UIImage imageNamed: @"grey.png"];
  32. //    UIImageView *imageView = [[UIImageView alloc] initWithImage: background];
  33.    
  34. //    [self.view sendSubviewToBack:imageView];
  35.    
  36. }
  37.  
  38. - (void)didReceiveMemoryWarning {
  39.     [super didReceiveMemoryWarning];
  40.     // Dispose of any resources that can be recreated.
  41. }
  42.  
  43. /*
  44. #pragma mark - Navigation
  45.  
  46. // In a storyboard-based application, you will often want to do a little preparation before navigation
  47. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  48.     // Get the new view controller using [segue destinationViewController].
  49.     // Pass the selected object to the new view controller.
  50. }
  51. */
  52. /*
  53. #pragma mark Image
  54. - (void)displayImage {
  55.     NSString *imagePath;
  56.     NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  57.     NSString *documentDirectoryPath = dirPaths[0];
  58.     NSString *calendarDir = [documentDirectoryPath stringByAppendingString:[NSString stringWithFormat:@"/CalendarFolder/"]];
  59.     NSArray *list = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:calendarDir error:nil];
  60.     for (NSString* file in list) {
  61.         if ([[file pathExtension] isEqualToString: @"png"]) {
  62. //            [[NSFileManager defaultManager] copyItemAtPath:file toPath:calendarDir error:nil];
  63.             imagePath = [calendarDir stringByAppendingPathComponent:file];
  64.         }
  65.     }
  66.     UIImage *image = [[UIImage alloc] initWithContentsOfFile:imagePath];
  67. //    [self.scheduleImage setImage:image];
  68. }
  69.  
  70.  
  71. /*
  72. - (void)displayImage {
  73.     NSString *imageName = [@"http://www.fnordware.com/superpng/pnggrad8rgb.png" lastPathComponent];
  74.     //UIImage *image = [UIImage imageNamed:@"imageName"];
  75.     //UIView *view = [[UIImageView alloc] initWithImage:image];
  76.     //[self.scheduleImage setImage:image];
  77.     NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  78.     NSString *documentDirectoryPath = dirPaths[0];
  79.     NSString *filePath = [documentDirectoryPath stringByAppendingString:[NSString stringWithFormat:@"/CalendarFolder/%@", imageName]];
  80.     UIImage *image = [[UIImage alloc] initWithContentsOfFile:filePath];
  81.     [self.scheduleImage setImage:image];
  82. }
  83. */
  84.  
  85.  
  86. #pragma mark Zooming and Panning
  87. -(void)addScrollView{
  88.     NSString *imagePath;
  89.     NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  90.     NSString *documentDirectoryPath = dirPaths[0];
  91.     NSString *calendarDir = [documentDirectoryPath stringByAppendingString:[NSString stringWithFormat:@"/CalendarFolder/"]];
  92.     NSArray *list = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:calendarDir error:nil];
  93.     for (NSString* file in list) {
  94.         if ([[file pathExtension] isEqualToString: @"png"]) {
  95.             //            [[NSFileManager defaultManager] copyItemAtPath:file toPath:calendarDir error:nil];
  96.             imagePath = [calendarDir stringByAppendingPathComponent:file];
  97.         }
  98.     }
  99.     UIImage *image = [[UIImage alloc] initWithContentsOfFile:imagePath];
  100.    
  101.     myScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, [ [ UIScreen mainScreen ] bounds ].size.width, [ [ UIScreen mainScreen ] bounds ].size.height)];
  102.     myScrollView.accessibilityActivationPoint = CGPointMake(500, 100);
  103.     scheduleImage = [[UIImageView alloc] initWithImage:image];
  104.     [myScrollView addSubview:scheduleImage];
  105.     myScrollView.minimumZoomScale = 0.5;
  106.     myScrollView.maximumZoomScale = 3;
  107.     myScrollView.contentSize = CGSizeMake(scheduleImage.frame.size.width,
  108.                                           scheduleImage.frame.size.height);
  109.     myScrollView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"grey.png"]];
  110.     myScrollView.delegate = self;
  111.     [self.view addSubview:myScrollView];
  112. }
  113.  
  114.  
  115. -(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
  116.     return scheduleImage;
  117. }
  118. -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
  119.     NSLog(@"Did end decelerating");
  120. }
  121. -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
  122.     //    NSLog(@"Did scroll");
  123. }
  124. -(void)scrollViewDidEndDragging:(UIScrollView *)scrollView
  125.                  willDecelerate:(BOOL)decelerate{
  126.     NSLog(@"Did end dragging");
  127. }
  128. -(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
  129.     NSLog(@"Did begin decelerating");
  130. }
  131. -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
  132.     NSLog(@"Did begin dragging");
  133. }
  134.  
  135. #pragma mark Buttons
  136. - (IBAction)backButton:(id)sender {
  137. }
  138. @end
Advertisement
Add Comment
Please, Sign In to add comment