Я новичок в разработке для iPhone,
Я хочу прокручивать свое изображение,
Вот мой фрагмент кода,
- (void)viewDidLoad {
UIImage *image1 = [UIImage imageWithContentsOfFile:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"bg.png"]];
self.imageView = [[UIImageView alloc] initWithImage:image1];
self.imageView.frame = (CGRect){.origin=CGPointMake(0.0f, 0.0f),.size=image1.size};
[self.scrollView addSubview:self.imageView];
self.scrollView.contentSize = image.size;
[self centerScrollViewContents];
}
- (void)centerScrollViewContents {
CGSize boundsSize = self.scrollView.bounds.size;
CGRect contentsFrame = self.imageView.frame;
if (contentsFrame.size.width < boundsSize.width) {
contentsFrame.origin.x = (boundsSize.width - contentsFrame.size.width) / 2.0f;
} else {
contentsFrame.origin.x = 0.0f;
}
if (contentsFrame.size.height < boundsSize.height) {
contentsFrame.origin.y = (boundsSize.height - contentsFrame.size.height) / 2.0f;
} else {
contentsFrame.origin.y = 0.0f;
}
self.imageView.frame = contentsFrame;
}
- (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView {
// Return the view that you want to zoom
return self.imageView;
}
также bg.png
не применяется к моему фону.
Любая помощь будет оценена.