Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // CalendarViewController.m
- // Радио СВЕТ
- //
- // Created by Bogdan Michalchuk on 10/24/14.
- // Copyright (c) 2014 Радио CBET. All rights reserved.
- //
- #import "CalendarViewController.h"
- @interface CalendarViewController ()
- @property (copy, nonatomic) UIImage *image;
- @property (weak, nonatomic) IBOutlet UIButton *backButton;
- @end
- @implementation CalendarViewController {}
- @synthesize scheduleImage;
- - (BOOL)prefersStatusBarHidden {
- return YES;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // [self displayImage];
- [self addScrollView];
- [self.view bringSubviewToFront:_backButton];
- // UIImage *background = [UIImage imageNamed: @"grey.png"];
- // UIImageView *imageView = [[UIImageView alloc] initWithImage: background];
- // [self.view sendSubviewToBack:imageView];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- /*
- #pragma mark Image
- - (void)displayImage {
- NSString *imagePath;
- NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentDirectoryPath = dirPaths[0];
- NSString *calendarDir = [documentDirectoryPath stringByAppendingString:[NSString stringWithFormat:@"/CalendarFolder/"]];
- NSArray *list = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:calendarDir error:nil];
- for (NSString* file in list) {
- if ([[file pathExtension] isEqualToString: @"png"]) {
- // [[NSFileManager defaultManager] copyItemAtPath:file toPath:calendarDir error:nil];
- imagePath = [calendarDir stringByAppendingPathComponent:file];
- }
- }
- UIImage *image = [[UIImage alloc] initWithContentsOfFile:imagePath];
- // [self.scheduleImage setImage:image];
- }
- /*
- - (void)displayImage {
- NSString *imageName = [@"http://www.fnordware.com/superpng/pnggrad8rgb.png" lastPathComponent];
- //UIImage *image = [UIImage imageNamed:@"imageName"];
- //UIView *view = [[UIImageView alloc] initWithImage:image];
- //[self.scheduleImage setImage:image];
- NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentDirectoryPath = dirPaths[0];
- NSString *filePath = [documentDirectoryPath stringByAppendingString:[NSString stringWithFormat:@"/CalendarFolder/%@", imageName]];
- UIImage *image = [[UIImage alloc] initWithContentsOfFile:filePath];
- [self.scheduleImage setImage:image];
- }
- */
- #pragma mark Zooming and Panning
- -(void)addScrollView{
- NSString *imagePath;
- NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentDirectoryPath = dirPaths[0];
- NSString *calendarDir = [documentDirectoryPath stringByAppendingString:[NSString stringWithFormat:@"/CalendarFolder/"]];
- NSArray *list = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:calendarDir error:nil];
- for (NSString* file in list) {
- if ([[file pathExtension] isEqualToString: @"png"]) {
- // [[NSFileManager defaultManager] copyItemAtPath:file toPath:calendarDir error:nil];
- imagePath = [calendarDir stringByAppendingPathComponent:file];
- }
- }
- UIImage *image = [[UIImage alloc] initWithContentsOfFile:imagePath];
- myScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, [ [ UIScreen mainScreen ] bounds ].size.width, [ [ UIScreen mainScreen ] bounds ].size.height)];
- myScrollView.accessibilityActivationPoint = CGPointMake(500, 100);
- scheduleImage = [[UIImageView alloc] initWithImage:image];
- [myScrollView addSubview:scheduleImage];
- myScrollView.minimumZoomScale = 0.5;
- myScrollView.maximumZoomScale = 3;
- myScrollView.contentSize = CGSizeMake(scheduleImage.frame.size.width,
- scheduleImage.frame.size.height);
- myScrollView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"grey.png"]];
- myScrollView.delegate = self;
- [self.view addSubview:myScrollView];
- }
- -(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
- return scheduleImage;
- }
- -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
- NSLog(@"Did end decelerating");
- }
- -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
- // NSLog(@"Did scroll");
- }
- -(void)scrollViewDidEndDragging:(UIScrollView *)scrollView
- willDecelerate:(BOOL)decelerate{
- NSLog(@"Did end dragging");
- }
- -(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
- NSLog(@"Did begin decelerating");
- }
- -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
- NSLog(@"Did begin dragging");
- }
- #pragma mark Buttons
- - (IBAction)backButton:(id)sender {
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment