Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CalendarViewController.h
- ------------------------
- #import "ViewController.h"
- #import <UIKit/UIKit.h>
- @interface CalendarViewController : ViewController<UIScrollViewDelegate> {
- UIScrollView *myScrollView;
- }
- - (IBAction)backButton:(id)sender;
- @property (nonatomic) IBOutlet UIImageView *scheduleImage;
- @end
- ------------------------
- ------------------------
- CalendarViewController.m File
- ------------------------
- @property (copy, nonatomic) UIImage *image;
- @synthesize scheduleImage;
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self displayImage];
- [self addScrollView];
- - (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)addScrollView{
- myScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, [ [ UIScreen mainScreen ] bounds ].size.width, [ [ UIScreen mainScreen ] bounds ].size.height)];
- myScrollView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"grey.png"]];
- myScrollView.accessibilityActivationPoint = CGPointMake(100, 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.delegate = self;
- [self.view addSubview:myScrollView];
- }
Advertisement
Add Comment
Please, Sign In to add comment