Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand correctly is that you want a scrollview with an image on it. It needs to be fullscreen to start with and you need to be able to zoom in. On top of that you want it to be able to rotate according to orientation.</p> <p>Well I've been prototyping with this in the past and if all of the above is correct the following code should work for you.</p> <p>I left a bit of a white area for the bars/custombars.</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; //first inits and allocs scrollView2 = [[UIScrollView alloc] initWithFrame:self.view.frame]; imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"someImageName"]]; [scrollView2 addSubview:imageView]; [self drawContent]; //refreshing the content [self.view addSubview:scrollView2]; } -(void)drawContent { //this refreshes the screen to the right sizes and zoomscales. [scrollView2 setBackgroundColor:[UIColor blackColor]]; [scrollView2 setCanCancelContentTouches:NO]; scrollView2.clipsToBounds = YES; [scrollView2 setDelegate:self]; scrollView2.indicatorStyle = UIScrollViewIndicatorStyleWhite; [scrollView2 setContentSize:CGSizeMake(imageView.frame.size.width, imageView.frame.size.height)]; [scrollView2 setScrollEnabled:YES]; float minZoomScale; float zoomHeight = imageView.frame.size.height / scrollView2.frame.size.height; float zoomWidth = imageView.frame.size.width / scrollView2.frame.size.width; if(zoomWidth &gt; zoomHeight) { minZoomScale = 1.0 / zoomWidth; } else { minZoomScale = 1.0 / zoomHeight; } [scrollView2 setMinimumZoomScale:minZoomScale]; [scrollView2 setMaximumZoomScale:7.5]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { // Portrait //the 88pxls is the white area that is left for the navbar etc. self.scrollView2.frame = CGRectMake(0, 88, [UIScreen mainScreen].bounds.size.width, self.view.frame.size.height - 88); [self drawContent]; } else { // Landscape //the 88pxls is the white area that is left for the navbar etc. self.scrollView2.frame = CGRectMake(0, 88, [UIScreen mainScreen].bounds.size.height, self.view.frame.size.width); [self drawContent]; } return YES; } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return self.imageView; } </code></pre> <p>I hope this will fix your troubles. If not leave a comment.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload