UIScrollView loading an image
Posted
by treasure
on Stack Overflow
See other posts from Stack Overflow
or by treasure
Published on 2010-06-07T20:18:33Z
Indexed on
2010/06/07
20:22 UTC
Read the original article
Hit count: 288
i must say i m not very good at this. and you probably know that (cause noone bothers to answer my questions) but i will keep on trying!!!
lol
here it goes!
i wanted to find an "easy" way to use the pinch/zoom function on my app! so i decided to use a UIScrollView. so far so good.
i load my image from an sqlite db like so:
- (void)loadView {
self.title = @"ScrollView";
imageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.backgroundColor = [UIColor blackColor];
self.view = imageView;}
and
- (void)viewWillAppear:(BOOL)animated {imageView.image = entity.imageA}
I followed a tutorial but i cnnot seem to be able to load my image at all:
- (void)vieDidLoad {
imageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.backgroundColor = [UIColor blackColor];
//when i have this it does load the image but when i cant load my own data!!
/*UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.austinbull.com/clonemines.png"]]]];
[self setMyImage:tempImageView];
[tempImageView release];*/
myScrollView.contentSize = CGSizeMake(imageView.frame.size.width, imageView.frame.size.height);
myScrollView.maximumZoomScale = 4.0;
myScrollView.minimumZoomScale = 0.75;
myScrollView.clipsToBounds = YES;
myScrollView.delegate = self;
[myScrollView addSubview:imageView];
self.view = scrollView; [window makeKeyAndVisible]; }
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return myImage; }
any help would be appreciated!
thank you for your time!
© Stack Overflow or respective owner